This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
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.
Joined: Feb 28, 2001
thanks sean for the correction, i reassesed/reread what i wrote and realized that i was describing the wrong method. thank u again