Six state of Java threads

Source: Internet
Author: User

Java threads have many kinds of states, the main six kinds, are created, run, sleep, wait, block and extinction Six, there are many down to 5 kinds, the sleep and wait to boil down to frozen;

is created: The thread is created, and the new Thread () is created after the threads.

Run: After the thread is created, the thread is started by the start () method, and the run () method of the thread is executed, and the thread is in the running state, which means that the thread is executing the Run method;

Sleep: The thread has sleep (), then can customize the time, the thread in the run as long as the call sleep (), the thread will go to sleep time, sleep state is the thread will not do anything, until the time of sleep to jump to the blocking state

Wait: The thread is through the wait () method to enter the waiting state, into the waiting state will not wake up, unless the main thread execution end, or is awakened, or is always waiting, wake up will enter the blocking state, Wake up through Notify () this method to achieve.

Blocking: When the CPU executes the program, the assigned process executes, the CPU that is not executed will be blocked, wait until the CPU is allocated to the time to run, and then sleep and wait for the wake to go to the blocking state, waiting for the CPU to execute;

Extinction: Is death, the run () method executes the process is finished, or the entire program is closed, the thread will die;

Six state of Java threads

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.