Java Process State

Source: Internet
Author: User

A thread state. A thread can is in one of the following states:

    • NEW
      A thread that has not yet started are in this state.
    • RUNNABLE
      A thread executing in the Java virtual machine was in this state.
    • BLOCKED
      A thread that's blocked waiting for a monitor lock are in this state.
    • WAITING
      A thread that's waiting indefinitely for another the thread to perform a particular action was in the this state.
    • TIMED_WAITING
      A thread that's waiting for another the thread to perform an action for up to a specified waiting time was in this state.
    • TERMINATED
      A thread that has exited is in the this state.

A thread can is in the only one state at a given point in time. These states is virtual machine States which don't reflect any operating system thread states.

    • NEW
      public static final Thread.state NEW
      Thread state for a thread which have not yet started.

    • RUNNABLE
      public static final Thread.state RUNNABLE
      Thread state for a runnable thread. A thread in the runnable state was executing in the Java virtual machine but it could be waiting for other resources from the Operating system such as processor.

    • BLOCKED
      public static final Thread.state BLOCKED
      Thread state for a thread blocked waiting for a monitor lock. A thread in the blocked state was waiting for a monitor lock to enter a synchronized block/method or reenter a synchronized Block/method after calling Object.wait .

    • Waiting
      public static final Thread.state waiting
      Thread state for a waiting thread. A thread is in the waiting state due to calling one of the following methods:
      • Object.waitWith no timeout
      • Thread.joinWith no timeout
      • LockSupport.park

      A thread in the waiting state was waiting for another thread to perform a particular action. For example, a thread of that have called object.wait () on an Object was waiting for another thread to call Object . Notify () or object.notifyall () on the that Object. A thread that have calledThread.Join () is waiting for a specified the thread to terminate.

    • Timed_waiting
      public static final Thread.state timed_waiting
      Thread state for a waiting thread with a specified waiting time. A thread is in the timed waiting state due to calling one of the following methods with a specified positive waiting time:
      • Thread.sleep
      • Object.waitWith timeout
      • Thread.joinWith timeout
      • LockSupport.parkNanos
      • LockSupport.parkUntil

    • TERMINATED
      public static final Thread.state TERMINATED
      Thread state for a terminated thread. The thread has completed execution.

    • Park
      public static void Park ()
      Disables the current thread to thread scheduling purposes unless the permit is available.

      If the permit is available then it's consumed and the call returns immediately; Otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things ha Ppens:

      • Some other thread invokes with the current thread as the unpark target;
      • Some other thread interrupts the current thread; Or
      • The call spuriously (that's, for no reason) returns.

      This method does the which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread upon return.

  • Parknanos
    public static void Parknanos (Long Nanos)
    Disables the current thread for thread scheduling purposes, for the specified waiting time, unless the permit is AVA Ilable.

    If the permit is available then it's consumed and the call returns immediately; Otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things hap Pens

      • Some other thread invokes with the current thread as the unpark target;
      • Some other thread interrupts the current thread; Or
      • The specified waiting time elapses; Or
      • The call spuriously (that's, for no reason) returns.

    This method does the which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread, or the elapsed time upon return.

    Parameters:
    nanos -The maximum
    number of nanoseconds to wait

  • Parkuntil
    public static void Parkuntil (long deadline)
    Disables the current thread for thread scheduling purposes, until the specified deadline, unless the permit is available.

    If the permit is available then it's consumed and the call returns immediately; Otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things hap Pens

      • Some other thread invokes with the current thread as the unpark target;
      • Some other thread interrupts the current thread; Or
      • The specified deadline passes; Or
      • The call spuriously (that's, for no reason) returns.

    This method does the which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread, or the current time upon return.

    Parameters:
    deadline -The absolute time, in milliseconds from the Epoch, to wait until

Java Process 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.