This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Confusion with Thread states
 
Similar Threads
Thread state questions in SCJP 1.4
conflict between K&B Thread concept & Dans Ques from exam#14?
Question from threads.
Thread.yield
Thread states?