[Java thread of the thread to be written termination Interrupt]

Reference: https: //bbs.csdn.net/topics/280082639

interrupt () method does not interrupt a running thread. This approach is in fact complete, throw an interrupt signal, so that he might become the thread exits the blocked state when the thread is blocked. More precisely, if the thread is Object.wait, one of three methods Thread.join and Thread.sleep blocked, then it receives an interrupt exception (InterruptedException), thereby terminating the blocking earlier state.

If the thread is not blocked, calling interrupt () will not work; otherwise, the thread will get an exception (the thread must be prepared to handle this situation), escape the blocked state.

Guess you like

Origin www.cnblogs.com/whutwxj/p/11304124.html