When an Thread.interrupt() is called on some thread, what happens to that thread?
When an Thread.interrupt() is called on some thread, what happens to that thread?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The target thread is “interrupted”. Mostly, a flag is set in that thread, which the thread can look at (with
Thread.interrupted()). If the target thread was currently blocked on some I/O orObject.wait(), then it is awakened with, respectively, anInterruptedIOExceptionor anInterruptedException.Thread interruption is a gentle way to nudge a thread. It is used to give threads a chance to exit cleanly, as opposed to
Thread.stop(), which is more like shooting the thread with an assault rifle.