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,
- New Born state
- Ready / Runnable
The thread that is just instantiated is in the new state. When start () method is
invoked, thread moves to the ready state from which it is moved automatically to
runnable state by the thread scheduler.
A thread being executed in JVM is in the running state.
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 the next runnable state.
A thread which is waiting for another thread (resource) indefinitely to carry out a specific action is under this state.
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 into this state that will never come back.