wood burning stoves 2.0*
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
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
Author

What does the Thread method interrupt() mean?

sam huang
Greenhorn

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


SCJP,SCWCD,SCBCD,MCSE
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
Sam,
Thread.interrupted()
Thread.isInterrupted()
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: http://aspose.com/file-tools
 
subject: What does the Thread method interrupt() mean?