During execution, a thread can be in one of the following five states:
The following figure shows the various thread states.
Java Thread Life Cycle
A thread will be called new born when the object of Thread class is created.
A thread will be called runnable when the start() method is invoked. After calling the start() method, the thread joins the thread queue and waits for its turn to get execute. The Thread scheduler provide equal amount of time to the same priority threads and if the thread doesn't get execute at the given time, it relinquishes the control and joins the thread queue at the end and again wait for its turn.
Running state means that the processor has given its time to thread for its execution. A running thread can relinquish its control in one of the followling reasons:
sleep() method is invoke and the thread goes into blocked state for specific time period.
yield() method is invoke to relinquish control from the current thread and put it back to the thread queue for execution.
wait() method is invoke and the thread goes into blocked state until some other thread doesn't invoke notify( ) or notifyAll() method.
A thread comes in blocked state when sleep() or wailt() method is invoke. When a thread blocks using sleep() method, it will automatically come in runnable state when the sleep time over. When a thread blocks using wait() method, it will come in runnable state when some other thread invokes notify( ) or notifyAll() method. A blocked thread sometimes called not runnable thread
Dead state means that a thread has finished its execution or its run() method and when the stop() method is invoke. The stop() method kills the thread and the thread doesn't work further.