Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stop a thread

 
Thomas Markl
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What wight cause the current thread to stop excutings?
A.thread of higher priority become ready
(yield-methode).
B.method sleep() be called.
C.method stop() be called
D.method suspend() be called.
E.method wait() be called
I think the answers are A, B, C, D, E.
Does a call to the wait method stop a thread?
Thanks for your answers.
Thomas.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming "stop" in this question does not mean
that the thread cannot resume at a later time, then all options are correct, in my opinion.
If "stop" in this question means a final halt of the thread's execution, then only the (deprecated) method stop() will do it.
wait() is a method of Object.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is testing your understanding of the thread life cycle and the different states that a thread can be in which are all described in The Life Cycle of a Thread Lesson of Sun's Java Tutorial on Threads.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic