• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusion with Thread states

 
Gitesh Ramchandani
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic