Threads in Java – Part II

Different thread states

A thread can be in a different states. once thread’s start() method has been called it does not mean that a thread will start working right away. Several factor determines thread working order and transition. Following are common threads states.

Ready to run state : thread starts life in ready to run state

Running state : thread is currently executing

Dead state : thread can’t run ever again. The following method can be used to determine either a thread is dead or alive.

1

finalbooleanisAlive()

Non runnable states: A running thread can transit to non runable state. A special transition is required to change thread state. A thread don’t go directly to running state, first it has to transit to ready to run state

Sleeping : threads sleeps for a certain amount of time. The following method can be used to set a thread to sleep.