Life cycle of a Thread in java

Life cycle of a Thread

A thread goes through different stages in its life cycle. A thread can be in five states. The life cycle of the thread in java is controlled by JVM. The java thread states are as follows:

Untitled

New

When you created an instance of Thread class, then it is in new state.

Runnable

After a new state, the thread bexomes runnable state. A thread in this state is considered to be executing its task.

Running

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

Waiting

Sometimes, a thread transitions to the waiting state while the thread waits for another thread to perform a task.

Dead

When run() method exist then runnable thread enters dead state

Leave a Reply

Your email address will not be published. Required fields are marked *