Take a picture first:
Threads under certain conditions, the state changes:
1. New status (new): Newly created a thread object
2. Ready state (Runnable): After the thread object is created, other threads call the object's start () method. The state of the thread is located in a pool of running threads that becomes operational and waits for the CPU to be used.
3. Running state (Running): The ready state of the thread gets the CPU and executes the program code.
4. Blocking state (Blocked): The blocking state is a temporary stop for a thread that has abandoned the CPU usage for some reason. Until the thread is in a ready state, the opportunity to go to the running state is reached. There are three types of blocking:
(i), waiting for blocking: The running thread executes the wait () method, and the JVM puts the thread into the waiting pool.
(ii), synchronous blocking: When a running thread acquires a synchronization lock on an object, the JVM puts the thread into the lock pool if the synchronization lock is occupied by another thread. (iii), other blocking: The running thread executes the sleep () or join () method, or when an I/O request is made, the JVM will place the thread in a blocked state. When the sleep () state times out, join () waits for the thread to terminate or time out, or the I/O process finishes, the thread is re-entered in a ready state.
5. Death status (Dead): The thread finishes executing or exits the run () method because of an exception, and the thread ends the life cycle.
A few small sums:
1, thread implementation There are two ways, one is to inherit the thread class, and the other is to implement the Runnable interface, but anyway, When we new this object, the thread enters the initial state,
2, when the object calls the start () method, it enters the operational state,  
3, enters the operational state, when the object is selected by the operating system, The CPU time slice will go into the running state,
4, after entering the running state, the situation is more complicated
4.1, the Run () method, or the main () method ends, The thread enters the terminating state;
4.2, when a thread calls its own sleep () method or another thread's join () method, it goes into a blocking state (which stops the current thread, but does not release the resources it occupies). When sleep () ends or join () ends, the thread enters the operational state and continues to wait for the OS to allocate the time slice;
4.3, the thread calls the yield () method, which means to discard the currently acquired CPU time slice, Back to the operational state, at this point in the same competition with other processes, the OS may then allow the process to enter the running state;
4.4, when the thread has just entered the operational state (note, not running), Discovers that the resource to be called is Synchroniza (synchronous), gets no lock tag, will immediately enter the lock pool state, waiting for the lock tag (at this point in the lock pool may already have other threads waiting to acquire the lock flag, when they are in the queue state, first-come-first-served), once the thread acquires the lock tag, Go to the operational state, wait for the OS to allocate CPU time slices;
4.5, when the thread calls the Wait () method, it enters the wait queue (which frees up all the resources in the state, and is different from the blocking state). is not automatically awakened, you must rely on other threads to invoke the Notify () or Notifyall () method to be awakened (because notify () just wakes up a thread, but we are not sure which thread is specifically awakened, perhaps the thread we need to wake up to cannot be awakened, Therefore, in the actual use, usually use the Notifyall () method, wake up some threads), the thread will be awakened into the lock pool, waiting for the lock token.
201709018 business days--transition of thread state