I want to complete threads that read data from Thread.interrupt () from the network flow, but the thread is blocked for read operations and hangs dead. How can I decide?

  • Use non-blocking reading. Asynchronous (non-blocking) procedures for reading from streams are contained in java.nio.* (Instead of java.io.* ). Here habrahabr.ru/post/235585 details the differences. - Pavel Krizhanovskiy
  • In the plus code I used the following method - when you need to close a thread that hangs on reading / writing, you need to close the "connection". Either send a signal (it will be harder here). A thread that read / wrote should understand that an error occurred and the socket is closed and correctly shut down the work of its thread. - KoVadim
  • If you have sockets, you need to configure a timeout. - Igor Kudryashov

0