Thread Life Cycle -
In the following figure, we are describing about Thread Life Cycle.
1)Create Thread – Thread can be create through Thread Class or Runnable interface.
2)New State – when any object of thread is being made by new Thread()
3)Runnable – When start method of thread is called means thread is now in runnable state.
4)Running – After Runnable state, based on the priorities of thread, is being to running state.
5)Dead – After running state, thread will go to Dead. Or it can be block states.
6)Block States – Thread can be in block state by calling wait(), sleep(), join() methods.
7)Sleep State – when sleep() method is called by thread, thread will go to the sleep state. Sleep State means, This thread is still alive and it can be go on runnable state. Thread has sleep method for passing the time in millisecond. And throw InterruptedException.
static void sleep(long millisecond) throws InterruptedException
8)Wait State – when wait() method is called by any thread, thread will goes to waiting state, and wait for notification by another thread. Through calling the notify() and notifyAll() method, thread will goes to runnable state.
9)Join State – When join() method is called by thread, it will go to the join state, when joined thread is completed the this thread again go to the running state.
10)Yield() - By invoking this method the current thread pause its execution temporarily and allow other threads to execute.