aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Confusion with Thread states Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Confusion with Thread states" Watch "Confusion with Thread states" New topic
Author

Confusion with Thread states

Gitesh Ramchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 274
source: Dan Chisholm

Which of the following thread state transitions model the lifecycle of a thread?

a. The Dead state to the Ready state
b. The Ready state to the Not-Runnable state
c. The Ready state to the Running state
d. The Running state to the Not-Runnable state
e. The Running state to the Ready state
f. The Not-Runnable state to the Ready state
g. The Not-Runnable state to the Running state

Ans: c,d,e,f
Doubt: Is option �g� not a valid one?


Thanks,
Gitesh
Ian Edwards
Ranch Hand

Joined: Aug 14, 2006
Posts: 107
As far as I am aware there isn't a Not-Runnable state or a Ready state. Perhaps Ready means Runnable, and Not-Runnable means Blocked etc. (see below).

If I remember correctly - when you create a thread its in the New state. When you call the start() method it becomes Runnable. When the JVM selects it to run it enters the Running state. From here it can go back to Runnable, or it can go to Blocked, Sleeping, or Waiting. If it is either of the last 3 states it has to go to Runnable first before it has a chance to be Running again.
Ian Edwards
Ranch Hand

Joined: Aug 14, 2006
Posts: 107
As far as I am aware there isn't a Not-Runnable state or a Ready state. Perhaps Ready means Runnable, and Not-Runnable means Blocked etc. (see below).

If I remember correctly - when you create a thread its in the New state. When you call the start() method it becomes Runnable. When the JVM selects it to run it enters the Running state. From here it can go back to Runnable, or it can go to Blocked, Sleeping, or Waiting. If it is either of the last 3 states it has to go to Runnable first before it has a chance to be Running again.
 
Consider Paul's rocket mass heater.
 
subject: Confusion with Thread states