This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads - suspend() and resume() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Threads - suspend() and resume()" Watch "Threads - suspend() and resume()" New topic
Author

Threads - suspend() and resume()

eskay kumar
Ranch Hand

Joined: Jul 22, 2000
Posts: 71
Hi,
This qn is from Jxam.

options are :
1)1 2 3 4
2)1 2 3
3)1 2
4)Nothing. This is not a valid way to create and start a thread.
5)1
Assuming deprecated methods will be considered 'ok' in the exam which is the correct ans.
ans given is 3) with the explaination :
"the code will run, but the thread suspends itself after displaying "2". Threads cannot un-suspend themselves (since they ARE suspended and therefore not running!)."
But i thought using resume() - would resume the thread, and the thread will execute again. Can soemone please expalin then what is the significance of resume - once a thread has been suspended, and how would one use it.
I have another favor to ask - i have a copy of RHE but the CD that came along with it is corrupted. I can't open the tester.jar file. Can someone please mail that to me at shilpakumar@hotmail.com
thanks a ton !
shilpa
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12327
    
    1
resume would resume the Thread BUT WHO WOULD CALL resume?
The only user Thread in the entire application is suspended indefinately! Sheeesh!
suspend and resume were used to enable multiple Threads to cooperate but are now deprecated because they did not work well with synchronized blocks.
public synchronized void doSomething(){
// stuff
suspend();
return ;
}
When the Thread is supended, the object is locked up as far as access by another Thread trying to call synchronized methods.
Bill


Java Resources at www.wbrogden.com
eskay kumar
Ranch Hand

Joined: Jul 22, 2000
Posts: 71
thanks Bill for replying !
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Threads - suspend() and resume()
 
Similar Threads
I need your help about a Thread question.(scjp03-Q56)
suspend() and resume()
Thread - suspend()
Thread Q
Threads: suspend/resume and join