Life cycle of a Thread


A life cycle of a thread consists of various stages such as


  • New,
  • Runnable,
  • Running,
  • Waiting and,
  • Terminated(Dead).
multithreading

New

A new thread remains in the new state until the program starts the thread.


Runnable

After the new thread is started, it becomes the runnable thread. In this state thread ready to execute the given task.


Running

The thread scheduler has selected then the thread is in running state.


Waiting

In some cases, the thread is waiting state while another thread to perform a task. Once the thread back to runnable state, then executes the waiting thread.


Terminated(Dead)

A runnable thread enters the terminated state when it exits the run() method.




OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.