What are the states in the lifecycle of a Thread?

Answer

A thread can have one of the following states during its lifetime:

  1. New: In this state, a Thread class object is created using a new operator, but the thread is not alive. Thread doesn't start until we call the start() method.
  2. Runnable: In this state, the thread is ready to run after calling the start() method. However, the thread is not yet selected by the thread scheduler.
  3. Running: In this state, the thread scheduler picks the thread from the ready state, and the thread is running.
  4. Waiting/Blocked: In this state, a thread is not running but still alive, or it is waiting for the other thread to finish.
  5. Dead/Terminated: A thread is in terminated or dead state when the run() method exits.

All Java Questions

Ask your interview questions on java

Write Your comment or Questions if you want the answers on java from java Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---