The life cycle of a thread, converting the graph into text is:
The thread is created by the new method, calls the start () method, the thread enters the ready state, waits for the system to be scheduled (the time slice rotation schedule). When the system is scheduled to enter the running state. Normal end or exit abnormally, the process goes into a dead state.
The running line Chengjo encounters the Sleep () method, the thread goes into slumber, does not yield a resource lock, the sleeping () method ends, the thread becomes ready, and waits for the system to be scheduled again.
The running thread may be waiting for IO, or it may enter a pending state. IO complete, into ready state.
The thread in the running state yield () method, the thread becomes ready state. (yield only give permission to higher than his own)
A thread in the running state encounters the Wait () method (the method of object), the thread is in a waiting state, a notify ()/notifyall () is required to wake the thread, the awakened thread is locked, the sync Lock is acquired, and then the line Cheng to the ready state.
The thread that is running is synchronized, plus it becomes a synchronization operation. is locked, the sync Lock is acquired, and the line Cheng to the ready state.