Several available states of the thread and several available states of the thread

Source: Internet
Author: User

Several available states of the thread and several available states of the thread
1. new: A new thread object is created. 2. runnable: After a thread object is created, other threads (such as the main thread) Call the start () method of the object. The thread in this status is located in the runable thread pool and is waiting to be selected by the thread scheduling to obtain the cpu usage right. 3. running: the runnable thread obtains the cpu time slice (timeslice) and executes the program code. 4. block: the blocking state means that the thread gives up the cpu usage right for some reason, that is, it gives up the cpu timeslice and stops running temporarily. It is not until the thread enters the runnable state that the cpu timeslice is re-obtained to the running state. Blocking is divided into three types: (1 ). waiting for blocking: The running thread executes o. in the wait () method, JVM will put this thread into the waiting queue (waitting queue. (2 ). synchronization congestion: When a running thread obtains the synchronization lock of an object, if the synchronization lock is occupied by another thread, the JVM puts the thread into the lock pool. (3 ). other blocking: The running Thread executes the Thread. sleep (long MS) or t. when the join () method or an I/O request is sent, JVM sets this thread to blocking. When the sleep () status times out, the join () waits for the thread to terminate or times out, or the I/O processing is completed, the thread is re-transferred to the runnable status. 5. dead: the execution of the run () and main () Methods ends, or the run () method exits due to exceptions. The dead thread cannot be re-generated.

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.