Tuesday, 20 March 2018

The Life Cycle Of Thread In Java


Thread Life Cycle


The life cycle of thread in java is controlled by Java virtual machine. The life cycle of the thread is as follow.

1.New
2.Runnable
3.Running
4.Non-runnable(Blocked)
5.Terminated




#1 New State

The new is the first state of thread life cycle.

The thread in new states if you create an instance of Thread class but before invocation of start() method.

#2 Runnable State


The Runnable is second state of thread life cycle.
The thread is in runnable state after the invocation of start() method but the thread scheduler has not selected it to be the running thread.

#3 Running State


This is a thread state. The thread is in running if the thread scheduler has selected it.

#4 Blocked State


This is the thread state when the thread is still alive but is currently not eligible to run.

#5 Terminated State


This is last of thread life cycle. The thread is in this state when its run() method exists.


Hit The Like Button For More Update



Popular posts