简体   繁体   中英

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. I know that interrupt() will cause thread premature release from waiting with an Interrupted Exception. Please correct me if I am wrong.

If you look at the JavaDoc of Thread.interrupt() you should see:

If this thread is blocked in an invocation of the wait(), ....

If this thread is blocked in an I/O operation ....

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM