Briefly explain high-level thread states?

The state chart diagram below describes the thread states. 

ƒ  Runnable : Waiting for its turn to be picked for execution by the thread schedular based on thread priorities.  

ƒ  Running: The processor is actively executing the thread code. It runs until it becomes blocked, or voluntarily gives up its turn with this static method Thread.yield(). Because of context switching overhead, yield() should not be used very frequently.  

ƒ  Waiting: A thread is in a blocked state while it waits for some external processing such as file I/O to finish.  

ƒ  Sleeping: Java threads are forcibly put to sleep (suspended) with this overloaded method: Thread.sleep(milliseconds), Thread.sleep(milliseconds, nanoseconds);  

ƒ  Blocked on I/O: Will move to runnable after I/O condition like reading bytes of data etc changes.  

ƒ  Blocked on synchronization: Will move to Runnable when a lock is acquired.  

ƒ  Dead: The thread is finished working.   

core java 12 Threads 12

FOLLOW US ON LinkedIn



Explore Tutu'rself