zoukankan      html  css  js  c++  java
  • java进程状态

    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
  • 相关阅读:
    Python采用struct处理二进制
    OVS处理upcall流程分析
    mybatis在CRUD
    leetcode先刷_Valid Sudoku
    [TS] Implement a doubly linked list in TypeScript
    [TS] Implement a singly linked list in TypeScript
    [Python] The get() method on Python dicts and its "default" arg
    [Javascript AST] 4. Continue: Report ESLint error
    [RxJS] Learn How To Use RxJS 5.5 Beta 2
    [NPM] Update published npm packages using np
  • 原文地址:https://www.cnblogs.com/hushaojun/p/4875064.html
Copyright © 2011-2022 走看看