Java Thread Status (GO)

Source: Internet
Author: User

Public static enum thread.state extends enum<thread.state> thread state.
A thread can be in one of the following states:
The state of a thread that has not been started by 1.NEW to date.
2.RUNNABLE The thread state of a thread that can run.
A thread in a running state is running in a Java virtual machine, but it may be waiting for other resources in the operating system, such as a processor.
3.BLOCKED is blocked and waiting for a thread state of the monitor lock.
A thread in a blocked state is waiting for a monitor lock to enter a synchronized block/method, or to enter the synchronized block/method again after calling Object.wait.
4.WAITING The thread state of a waiting thread. A thread is waiting because it calls one of the following methods:

    • Object.wait with no time-out value
    • Thread.Join with no time-out value


Locksupport.park
A thread that is waiting waits for another thread to perform a specific operation.
For example, a thread that has already called object.wait () on an object is waiting for another thread to call Object.notify () or Object.notifyall () on that object.
A thread that has already called thread.join () is waiting for the specified thread to terminate.
5.timed_waiting The thread state of a waiting thread with a specified wait time. A thread is in a timed wait state because it calls one of the following methods with the specified positive wait time:

    • Thread.Sleep
    • Object.wait with time-out value
    • Thread.Join with time-out value
    • Locksupport.parknanos
    • Locksupport.parkuntil


6.TERMINATED
The thread state of the thread that has been terminated. The thread has finished executing.
Note: At a given point in time, a thread can only be in one state. These states are virtual machine states, and they do not reflect all operating system thread states.
To show the state of the thread at run time and its transformation, I drew the following diagram

Http://www.blogjava.net/cpegtop/articles/377980.html

Java Thread Status (GO)

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.