Thread Life cycle

Concept's of Multithreading 

Life cycle of a Thread.

There are five states are available in the Thread

http://www.journaldev.com/wp-content/uploads/2012/12/Thread-Lifecycle-States.png
  1. New
  2. Runnable
  3. Running
  4. Blocked/Non-Runnable/Waiting
  5. Dead/Terminated

New:

      When we creating new Thread class or using new operator, thread state is New. At this new state the start() method wasn't not invoked.


Runnable:

     In this state, the thread will invoke the start() method, Now the Thread is eligible for running. But thread will be running after the schedule.

Running:

     The Thread scheduler will select the Thread from the thread runnable thread pool. Once the thread is selected the Runnable thread state is changed as Running thread.

Blocked (or) Non-Runnable (or) Waiting:

     A thread can be waiting for the another resource such as Ex. IO resources, to join the another thread is known as waiting state. Once the thread waiting time expires the waiting state thread will moved to the Runnable state.

Dead (or) Terminated:

      The thread state will changed as Dead (or) Terminated when the thread will complete it's task. Also the thread will dead after the run() method exits.

    

No comments:

Post a Comment