Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ambiguous question on thread?

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Under which circumstances will a thread stop?
Select one correct answer
1.The run() method that the thread is executing ends
2.call to the start() method of the Thread object returns
3.suspend() method is called on the thread object
4.wait() method is called on the thread object
I think this question will ahve more than 1 option as answer. This question is from the PGJC exam.
Any explanations?
-sanjana
 
Ranch Hand
Posts: 168
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody, correct me if I'm wrong. I just finished reading K&B book chapter 9 (Threads).
1.The run() method that the thread is executing ends
This is correct.
2.call to the start() method of the Thread object returns
This is wrong.
Call to the start() method creates a new thread. After returning from start() method, the caller thread continues its execution, and the new thread is in runnable state.
3.suspend() method is called on the thread object
This is wrong.
According to its name, this method only suspend its execution, not stop it.
4.wait() method is called on the thread object
This is wrong.
If a thread call wait() method of another thread, the caller thread register itself to the second thread's notify list and change its state to wait state.
[ January 22, 2004: Message edited by: Yosi Hendarsjah ]
[ January 22, 2004: Message edited by: Yosi Hendarsjah ]
 
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic