Life Cycle of a Thread

 

Life-Cycle-of-a-Thread-4

Life Cycle States :

1.New State:

A thread has been created but not started yet. A thread will be started by calling its start() method.

2.Runnable State:

This state is also called ready to run stage also called queue. A thread starts in runnable state by calling start() method.
The Thread scheduler decides which thread runs and how long.

3.Running State:

If a Thread is executing that means Thread is in Running stage.

4.Dead State:

Once a Thread reached dead state it can not run again.

5. Non runnable States:

A Running Thread transit to one of the non runnable states, depending upon the circumstances.
A Thread remains non runnable until a special transition occurs.
A Thread does not go directly to the running state from non runnable state.
But transits first to runnable state.

  • Sleeping: The Threas sleeps for specified amount of time.
  • Blocked for I/O: The Thread waits for a blocking operation to complete.
  • Blocked for join completion: The Thread waits for completion of another Thread.
  • Waiting for notification: The Thread waits for notification another Thread.
  • Blocked for lock acquisition: The Thread waits to acquire the lock of an object.

 

 

 

   

Share :Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Comments are closed