[英]What happens when interrupt on thread which does not waiting for a lock
I have query that if I invoked interrupt on a thread A which is not in Waiting Status. 我有一个疑问,如果我在不处于等待状态的线程A上调用了中断。 I know that interrupt() will cause thread premature release from waiting with an Interrupted Exception.
我知道interrupt()会导致线程过早释放,而不会等待中断异常。 Please correct me if I am wrong.
如果我错了,请纠正我。
If you look at the JavaDoc of Thread.interrupt() you should see: 如果查看Thread.interrupt()的JavaDoc,您应该看到:
If this thread is blocked in an invocation of the wait(), ....
如果在调用wait()时阻塞了此线程,则...。
If this thread is blocked in an I/O operation ....
如果此线程在I / O操作中被阻止....
If this thread is blocked in a Selector ....
如果此线程在选择器中被阻止....
If none of the previous conditions hold then this thread's interrupt status will be set .
如果上述条件均不成立,则将设置此线程的中断状态 。
So - essentially, the thread's interrupt status will be set , and that's it! 所以-本质上,线程的中断状态将被设置 ,仅此而已!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.