thread life cycle

The life cycle of the thread in java is controlled by JVM. 

A thread can be in one of the five states.
New
Runnable
Running
Non-Runnable (Blocked)
Terminated

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

2) 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. 

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

4) Non-Runnable (Blocked)
This is the state when the thread is still alive, but is currently waiting for other thread to finish using thread join or it can be waiting for some resources to available

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s