aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads & Interrupt Method... 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 "Threads & Interrupt Method..." Watch "Threads & Interrupt Method..." New topic
Author

Threads & Interrupt Method...

Shah Chunky
Ranch Hand

Joined: Dec 27, 2000
Posts: 116

Hello All...
Can someone Explain me What exactly is the Meaning of Interrupt Method...
I am referring Java 2 Cert - RHE (1999 Edition)
According to the book, On page 204 (at end of the page) it says that
"If a thread might need to be killed from Another Thread, then u should send it an
interrupt from Killing method."

On page 210 (just before the Figure 7.3) it says that
"A sleeping thread that receives an interrupt() call moves immediately into Ready State."

What i don't understand is that according to page 204, the method Interrupt will kill the thread
& according to page 210, the interrupt() will make the sleeping thread move it to Ready state
which according to my knowledge means the thread is not killed.
Can someone explain ?
Thanks.


Shah Chunky - Sun Certified Java2 Programmer.
lee dalais
Ranch Hand

Joined: Feb 28, 2001
Posts: 67
hi Shah
from my understanding:
what interrupt() does is that it temporarely suspends the currently running thread, to give the thread schedular a chance to check if there are any other threads(generally higher priority threads) that it can put into the running state, if not, then the currently running thread carries on running.
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
Lee, the method you describe is the static yield method. The interrupt method is used in place of the deprecated stop() method from an earlier version of the jdk. So for a thread in a running state, it will interrupt that the currently running state. If it is sleeping then a call to the method will interrupt the sleeping thread, and return it to a ready state. I'm not sure about exceptions thrown. The interrupt() is an instance method of class Thread.
lee dalais
Ranch Hand

Joined: Feb 28, 2001
Posts: 67
thanks sean for the correction, i reassesed/reread what i wrote and realized that i was describing the wrong method.
thank u again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads & Interrupt Method...
 
Similar Threads
Threads
Threads- interrupt()
What does the Thread method interrupt() mean?
Sleep and Yield.. Am i correct??
interrupt() method