This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What does the Thread method interrupt() mean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What does the Thread method interrupt() mean?" Watch "What does the Thread method interrupt() mean?" New topic

What does the Thread method interrupt() mean?

sam huang

Joined: Dec 31, 2002
Posts: 28
Thanks in advence.

Jasper Vader
Ranch Hand

Joined: Jan 10, 2003
Posts: 284
if a thread might need to be killed from another thread, don't use the stop() method, instead, call interrupt() on it.
if a thread is sleeping and it receives an interrupt() call, it moves immediately into the Ready state, and when it runs, it will execute its InterruptedException handler.

giddee up
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
can be used for testing if a thread was err.. interrupt()
Please check the API for the difference between them.
If a thread is joining, sleeping or waiting and it is interrupted, it would abandon the state and its "InterruptedException" handler would be executed.

SCJP2. Please Indent your code using UBB Code
I agree. Here's the link:
subject: What does the Thread method interrupt() mean?