I have the following setup: First I have a GUI with Swift as my mainframe. Then I want to press a button and start a new Thread. If I press the button again the Thread should stop. The Thread is waiting for incomming TCP-Connection:
ServerSocket clientSocket = welcomeSocket.accept();
Now I tried to call in the GUI thread.interrupt();
to stop the Thread but it's not working due .accept is a blocking system call. What can I do to stop the Thread in waiting for a new connection? I don't want to use thread.stop()
because it's deprecated.
Any solutions for it?