Diagram and text description of the Java thread lifecycle

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.