public class AbstractQueuedSynchronizer.ConditionObject
extends Object implements Condition, Serializable
| java.lang.Object | |
| java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject | |
AbstractQueuedSynchronizer条件实现作为 Lock实现的基础。
此类的方法文档描述了机制,而不是从锁定和条件用户的角度来看行为规范。 该类的导出版本通常需要伴随着描述依赖于相关联的AbstractQueuedSynchronizer条件语义的文档。
这个类是可序列化的,但所有字段都是暂时的,所以反序列化的条件没有服务员。
Public constructors |
|
|---|---|
AbstractQueuedSynchronizer.ConditionObject() 创建一个新的 |
|
公共方法(Public methods) |
|
|---|---|
final void |
await() 实施中断条件等。 |
final boolean |
await(long time, TimeUnit unit) 实现定时条件等待。 |
final long |
awaitNanos(long nanosTimeout) 实现定时条件等待。 |
final void |
awaitUninterruptibly() 实现不间断条件等待。 |
final boolean |
awaitUntil(Date deadline) 实现绝对定时条件等待。 |
final void |
signal() 将等候时间最长的线程(如果存在)从此状态的等待队列移至拥有锁的等待队列。 |
final void |
signalAll() 将此条件的等待队列中的所有线程移至拥有锁的等待队列。 |
Protected methods |
|
|---|---|
final int |
getWaitQueueLength() 返回等待此条件的线程数的估计值。 |
final Collection<Thread> |
getWaitingThreads() 返回包含可能在此Condition上等待的线程的集合。 |
final boolean |
hasWaiters() 查询是否有线程正在等待这种情况。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
java.util.concurrent.locks.Condition
|
|
AbstractQueuedSynchronizer.ConditionObject ()
创建一个新的 ConditionObject实例。
void await ()
实施中断条件等。
getState(). release(int) with saved state as argument, throwing IllegalMonitorStateException if it fails. acquire(int) with saved state as argument. | 抛出异常(Throws) | |
|---|---|
InterruptedException |
|
boolean await (long time,
TimeUnit unit)
实现定时条件等待。
getState(). release(int) with saved state as argument, throwing IllegalMonitorStateException if it fails. acquire(int) with saved state as argument. | 参数(Parameters) | |
|---|---|
time |
long: the maximum time to wait |
unit |
TimeUnit: the time unit of the time argument |
| 返回(Returns) | |
|---|---|
boolean |
false if the waiting time detectably elapsed before return from the method, else true |
| 抛出异常(Throws) | |
|---|---|
InterruptedException |
|
long awaitNanos (long nanosTimeout)
实现定时条件等待。
getState(). release(int) with saved state as argument, throwing IllegalMonitorStateException if it fails. acquire(int) with saved state as argument. | 参数(Parameters) | |
|---|---|
nanosTimeout |
long: the maximum time to wait, in nanoseconds |
| 返回(Returns) | |
|---|---|
long |
an estimate of the nanosTimeout value minus the time spent waiting upon return from this method. A positive value may be used as the argument to a subsequent call to this method to finish waiting out the desired time. A value less than or equal to zero indicates that no time remains. |
| 抛出异常(Throws) | |
|---|---|
InterruptedException |
|
void awaitUninterruptibly ()
实现不间断条件等待。
getState(). release(int) with saved state as argument, throwing IllegalMonitorStateException if it fails. acquire(int) with saved state as argument. boolean awaitUntil (Date deadline)
实现绝对定时条件等待。
getState(). release(int) with saved state as argument, throwing IllegalMonitorStateException if it fails. acquire(int) with saved state as argument. | 参数(Parameters) | |
|---|---|
deadline |
Date: the absolute time to wait until |
| 返回(Returns) | |
|---|---|
boolean |
false if the deadline has elapsed upon return, else true |
| 抛出异常(Throws) | |
|---|---|
InterruptedException |
|
void signal ()
将等候时间最长的线程(如果存在)从此状态的等待队列移至拥有锁的等待队列。
| 抛出异常(Throws) | |
|---|---|
IllegalMonitorStateException |
if isHeldExclusively() returns false |
void signalAll ()
将此条件的等待队列中的所有线程移至拥有锁的等待队列。
| 抛出异常(Throws) | |
|---|---|
IllegalMonitorStateException |
if isHeldExclusively() returns false |
int getWaitQueueLength ()
返回等待此条件的线程数的估计值。 实现getWaitQueueLength(ConditionObject) 。
| 返回(Returns) | |
|---|---|
int |
the estimated number of waiting threads |
| 抛出异常(Throws) | |
|---|---|
IllegalMonitorStateException |
if isHeldExclusively() returns false |
Collection<Thread> getWaitingThreads ()
返回包含可能在此Condition上等待的线程的集合。 实现getWaitingThreads(ConditionObject) 。
| 返回(Returns) | |
|---|---|
Collection<Thread> |
the collection of threads |
| 抛出异常(Throws) | |
|---|---|
IllegalMonitorStateException |
if isHeldExclusively() returns false |
boolean hasWaiters ()
查询是否有线程正在等待这种情况。 实现hasWaiters(ConditionObject) 。
| 返回(Returns) | |
|---|---|
boolean |
true if there are any waiting threads |
| 抛出异常(Throws) | |
|---|---|
IllegalMonitorStateException |
if isHeldExclusively() returns false |