Life Cycle of Thread in java
A thread can be in one of the five states. According to sun, there is only 4 states in thread life cycle in java new, runnable, non-runnable and terminated. There is no running state.
But for better understanding the threads, we are explaining it in the 5 states. The life cycle of the thread in java is controlled by JVM. The java thread states are as follows
4) Non-Runnable (Blocked)
5) Terminated / Dead
Once we created a thread object then it is said to be in New or Born State.
If we call start() method on thread object then the thread will enter into Ready State or Runnable State.
If Thread Scheduler allocates CPU for thread then thread will enter into Running state.
Non-Runnable (Blocked)/Wating State
This is the state when the thread is still alive, but is currently not eligible to run.
Terminated / Dead State
If run() method completes then thread will enter into Dead State.
What next ?
Getting and Setting Name