State transitions between threads:
1. NEW: A new Thread object was created.
2. Operational (runnable): When a thread object is created, other threads (such as the main thread) invoke the object's start () method. The thread in the state is in the running thread pool, waiting to be selected by the thread dispatch to obtain the right to use the CPU.
3. Run (running): The Running State (runnable) thread obtains the CPU time slice (timeslice), executes the program code.
4. Blocking (block): Blocking state refers to the thread for some reason to give up the use of CPU, that is, let the CPU TimeSlice, temporarily stop running. Until the thread enters a running (runnable) state, it has the opportunity to get the CPU TimeSlice to the running (running) state again. The blocking situation is divided into three types:
(i). Wait for blocking: The running (running) thread executes the o.wait () method, and the JVM puts that thread into the wait queue (waitting queue).
(ii). Synchronous blocking: A thread that runs (running) is placed in the lock pool if the synchronization lock is occupied by another thread when it acquires a synchronized lock on the object.
(iii). Other blocking: The running thread executes the thread.sleep (long ms) or T.join () method, or when an I/O request is made, the JVM puts the thread into a blocking state. When the sleep () state times out, join () waits for the thread to terminate or timeout, or the I/O process completes, the thread is transferred back into a runnable state.
5. Death (dead): Thread Run (), the main () method finishes executing, or the run () method is exited because of an exception, the thread ends the lifecycle. The thread of death cannot be resurrected again.