File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's Question : Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic
Author

Dan's Question : Thread

David Jones
Greenhorn

Joined: Dec 26, 2003
Posts: 27
After invoking the wait method on an object, obj1, a thread, T1, will remain in the wait set of obj1 until which of the following occurs?
a. Another thread invokes the notify method on the object, obj1, and T1 is selected to move out of the wait set
b. Another thread invokes the notifyAll method on the object
c. Another thread invokes the resume method on thread T1
d. Another thread interrupts thread T1
e. The priority of thread T1 is increased
f. A specified timeout period has elapsed
g. Another thread invokes the join method on thread T1
Answer : A, B, D, F
Could anyone provides an example to demostrate how a thread interrupts thread T1? Using notify or notifyAll is the interrupts? Or using other methods?
Thanks,
David
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
David, please see the javadoc for the interrupt method of the Thread class.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
David Hadiprijanto
Ranch Hand

Joined: Sep 14, 2003
Posts: 52
Below is a pretty simple sample code.
The output should be :
T1 start.
T1 waiting.
Main thread interrupting.
T1 interrupted.
T1 done.
Hope this helps.
David Jones
Greenhorn

Joined: Dec 26, 2003
Posts: 27
Hi David,
Thanks for your examples.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dan's Question : Thread