|New to Runnable||
A thread object's
|Runnable to Running||The task scheduler schedules the thread based on the thread's priority and its scheduling algorithm.|
|Running to Runnable||
A thread invokes its
|Running to Waiting||
A thread invokes its sleep() method; or a thread blocks on I/O; or a thread waits for a lock; or a thread invokes an object's
|Waiting to Runnable||
A thread has finished sleeping; or an I/O operation is completed; or a thread
acquires a lock; or a thread is notified that an object is available;
or a thread's
|Running to Dead||
Thread.stop()is almost impossible to use correctly without violating concurrent safety, as
stop()kills the thread immediately, without giving it any opportunity to recover objects to legal states. This is in direct opposition to principles such as concurrent safety, and so should never be used.
suspend()mechanism does not release any monitors it holds when it suspends, so any other thread that attempts to accesses those monitors will deadlock. In practice, this mechanism produces race conditions between these deadlocks and resume(), that render this group of methods unusable.
suspend()if it had been. All of these deprecated methods should always be avoided. Instead, a set of safe alternative patterns that achieve the same intended aims as the preceding methods have been developed. A good example of one of these patterns is the run-until shutdown pattern.