Five states of the thread family two thread

Source: Internet
Author: User
Tags switches

Threads have 5 states, namely new, blocked, run, dead, dormant, waiting.

The explanations in the API are shown in 1

Figure 1

Figure 2

Explain the process of Figure 2 above.

1, new a thread object with a state of new state.

2, execute Start (), if the CPU is now idle, then switch to the running state, otherwise switch to the blocking state.

3, Thread execution sleep (), switch to hibernation, after the sleep time expires, automatically switch to (run or block)

4. Execute wait (), switch to the wait state, or wait until notifiy () is executed.

5. The thread switches to the dead state after the run () is executed in the threads. The thread manually executes stop () and also switches directly to the death state.

Five states of the thread family two thread

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.