File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads - suspend() and resume()

 
eskay kumar
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
eskay kumar
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Bill for replying !
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic