Stop/Interrupt threads blocked on waiting input from socket

后端 未结 6 1784
自闭症患者
自闭症患者 2021-01-04 04:12

As the title says I need a way to stop or interrupt a thread that is blocked waiting on an input from the socket.

6条回答
  •  抹茶落季
    2021-01-04 04:54

    Thread.interrupt() should be the method you're looking for. Be sure that your input-accessing methods also check for InterruptedException and ClosedByInterruptException.

    Also look at the corresponding page in the Sun Concurrency Tutorial, as another solution suggests.

提交回复
热议问题