码迷,mamicode.com
首页 > 编程语言 > 详细

java进程状态

时间:2015-10-13 18:41:16      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:

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

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

A thread can be in only one state at a given point in time. These states are virtual machine states which do not reflect any operating system thread states.

 

 

  • NEW

    public static final Thread.State NEW
    Thread state for a thread which has not yet started.

  • RUNNABLE

    public static final Thread.State RUNNABLE
    Thread state for a runnable thread. A thread in the runnable state is executing in the Java virtual machine but it may 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 is 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:

    A thread in the waiting state is waiting for another thread to perform a particular action. For example, a thread that has 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 calledThread.join() is waiting for a specified thread to terminate.

  • 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 for thread scheduling purposes unless the permit is available.

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

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

    This method does not report 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 up to the specified waiting time, unless the permit is available.

    If the permit is available then it is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

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

    This method does not report 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 is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

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

    This method does not report 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进程状态

标签:

原文地址:http://www.cnblogs.com/hushaojun/p/4875064.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!