How to stop / destroy a stream by name? It is created like this:

Thread t = new Thread()... 

Using interrupt() does not work, the thread still continues to work. Using stop() stops the stream, but it doesn’t like to use the deprecated functions.

  • Interrupting threads is generally a bad practice. - Qwertiy

1 answer 1

  1. This is possible only if you do something in a loop and check the value of the flag. Then you can set the flag by this method.

  2. Or if there is a socket waiting for a connection, you can also close it.

For details - here .