Java Thread Life Cycle

By | 2015-04-25T12:22:25+05:30 April 19th, 2015|java|

The Java thread life cycle is similar to that of the life cycle of processes that runs in an
operating system. During the life cycle, the thread shifts from one state to other based on the operation carried out by it or carried out on it. The entire life cycle of the thread is maintained by JVM.  Java thread can remain one of the states given below,

1) New Born state

2) Ready / Runnable

3) Running

4) Dead

5) Blocked

6) Sleep

7) wait

8) Suspend

Thread-Life-Cycle

New:

Thread that is just instantiated is in the new state. When start () method is
invoked, thread moves to ready state from which it is moved automatically to
runnable state by thread scheduler.

RUNNABLE (ready_running):

A thread being executed in JVM is in the running state.

BLOCKED:

A thread which is blocked and waiting for a monitor lock is under this state. This can occur if a thread performs an input/output operation and shifts to next runnable state.

Waiting:

A thread which is waiting for another thread (resource) indefinitely to carry out a specific action is under this state.

TIMED_WAITING (sleeping):

A thread which is waiting for other thread to carry out an action up to a particular waiting time is under this state.
TERMINATED (dead): A thread which has exited is under this state. Once a thread entered in to this state that will never come back.

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment