States of thread
- Waiting for some action
Process of Thread
Create Thread –> start thread –> Run
A thread is said to be in running state when it is being executed. This thread has access to CPU.
A thread in this state is ready for execution, but is not being currently executed. Once a thread in the ready state gets access to the CPU, it gets converted to running state.
A thread reaches “dead” state when the run method has finished execution. This thread cannot be executed now.
In this state the thread is waiting for some action to happen. Once that action happens, the thread gets into the ready state. A waiting thread can be in one of the following states: Sleeping Suspended, Blocked, Waiting for monitor.
Thread in execution can invoke the sleep () to cease executing & free CPU. Thread would go to the “sleep” state for the specified amount of time, after which it would move to the “ready” state. It does not release lock.
Dimit Chadha CORE-JAVA · CONCURRENCY
core-java threads concurrency