类 ThreadGate
- java.lang.Object
-
- org.apache.felix.framework.util.ThreadGate
-
public class ThreadGate extends java.lang.ObjectThis 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()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 booleanawait(long timeout)Wait for the gate to open.java.lang.ObjectgetMessage()Returns the message object associated with the gate; the message is just an arbitrary object used to pass information to the waiting threads.voidopen()Open the gate and release any waiting threads.voidsetMessage(java.lang.Object msg)Sets the message object associated with the gate.
-
-
-
方法详细资料
-
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.InterruptedExceptionWait 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.
-
-