Home Navigation

Sunday 27 November 2016

Life cycle of a Thread (Thread States)

There are 4 states in thread life cycle in java new, runnable, non-runnable and terminated. There is no running state.

New: The thread is in new state if you create an instance of Thread class but before the invocation of start() method.

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

Running: The thread is in running state if the thread scheduler has selected it.

Non-Runnable (Blocked) : This is the state when the thread is still alive, but is currently not eligible to run.

Terminated: A thread is in terminated or dead state when its run() method exits.

No comments:

Post a Comment