类 ThreadGate


  • public class ThreadGate
    extends java.lang.Object
    This class implements a simple one-shot gate for threads. The gate starts closed and will block any threads that try to wait on it. Once opened, all waiting threads will be released. The gate cannot be reused.
    • 构造器概要

      构造器 
      构造器 说明
      ThreadGate()  
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      boolean await​(long timeout)
      Wait for the gate to open.
      java.lang.Object getMessage()
      Returns the message object associated with the gate; the message is just an arbitrary object used to pass information to the waiting threads.
      void open()
      Open the gate and release any waiting threads.
      void setMessage​(java.lang.Object msg)
      Sets the message object associated with the gate.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • ThreadGate

        public ThreadGate()
    • 方法详细资料

      • open

        public void open()
        Open the gate and release any waiting threads.
      • getMessage

        public java.lang.Object getMessage()
        Returns the message object associated with the gate; the message is just an arbitrary object used to pass information to the waiting threads.
        返回:
        the message object associated with the gate.
      • setMessage

        public void setMessage​(java.lang.Object msg)
        Sets the message object associated with the gate. The message object can only be set once, subsequent calls to this method are ignored.
        参数:
        msg - the message object to associate with this gate.
      • await

        public boolean await​(long timeout)
                      throws java.lang.InterruptedException
        Wait for the gate to open.
        返回:
        true if the gate was opened or false if the timeout expired.
        抛出:
        java.lang.InterruptedException - If the calling thread is interrupted; the gate still remains closed until opened.