state transitions between threads:
1. New: A new Thread object has been created.
2. Operational (runnable): After the thread object is created, other threads (such as the main thread) call the object's start () method. The thread in this state is in a pool of running threads, waiting for the thread to be dispatched to get the CPU right.
3. Run (running): The Running State (runnable) thread obtains the CPU time slice (TimeSlice) and executes the program code.
4. Block: Blocking state refers to a thread that has given up the CPU for some reason, or let the CPU TimeSlice, temporarily stop running. Until the thread enters the operational (runnable) state, there is a chance to get the CPU TimeSlice again to the run (running) state. There are three types of blocking:
(i). Wait for blocking: the thread that is running (running) executes the o.wait () method, and the JVM puts the thread into the waiting queue (the waitting queues).
(b). Synchronous blocking: When a thread running (running) acquires a synchronization lock on an object, if the synchronization lock is occupied by another thread, the JVM puts the thread into the lock pool.
(iii). Other blocking: The thread that runs (running) executes the thread.sleep (long ms) or T.join () method, or when an I/O request is made, the JVM will place the thread in a blocked state. When the sleep () state time-out, join () waits for the thread to terminate or times out, or the I/O process is complete, the thread is re-transferred to the operational (runnable) state.
5. death (dead): The thread Run (), main () method execution ends, or the run () method is exited due to an exception, the thread ends the life cycle. The thread of death cannot be resurrected again.
State transitions between Java threads