Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ready State

 
V Bose
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the context of threads, whats the difference between a New,Runnable and Ready state. Dan Chisolms questions mention the Ready state...
[ May 18, 2004: Message edited by: V Bose ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread States from the Java Tutorial
 
Anil Hulikal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Khalid Mughal and Rolf Rasmussen's book has this explanation in section 9.5. (It would be much easier to follow with the state diagram they have given in the book).


Ready-to-run state
A thread starts life in the Ready-to-run state (see p. 369).
Running state
If a thread is in the Running state, it means that the thread is currently executing (see p. 369).
Dead state
Once in this state, the thread cannot ever run again (see p. 380).
Non-runnable states
A running thread can transit to one of the non-runnable states, depending on the circumstances. A thread remains in a non-runnable state until a special transition occurs. A thread does not go directly to the Running state from a non-runnable state, but transits first to the Ready-to-run state.
The non-runnable states can be characterized as follows:
1. Sleeping: The thread sleeps for a specified amount of time (see p. 370).
2. Blocked for I/O: The thread waits for a blocking operation to complete (see p. 380).
3. Blocked for join completion: The thread awaits completion of another thread (see p. 377).
4. Waiting for notification: The thread awaits notification from another thread (see p. 370).
5. Blocked for lock acquisition: The thread waits to acquire the lock of an object (see p. 359)


Basically, once a thread (of execution) is started with start(), it won't start "running" immediately, instead it enters into "ready to run state" to be picked up by the scheduler.

Regards,
Anil
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good post anil.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic