public class AbstractQueuedSynchronizer.ConditionObject extends Object implements Condition, Serializable
AbstractQueuedSynchronizer作为一个
Lock实施的基础条件的实现。
本类的方法文档介绍了力学,而不是行为规范的角度来看,锁定和条件用户。出口版本的这类一般会需要附带文档描述的条件下,依靠语义的相关AbstractQueuedSynchronizer。
这个类是可序列化的,但所有字段都是短暂的,所以反序列化的条件都没有服务员。
| Constructor and Description |
|---|
ConditionObject()
创建一个新的
ConditionObject实例。
|
| Modifier and Type | Method and Description |
|---|---|
void |
await()
实施可中断条件等。
|
boolean |
await(long time, TimeUnit unit)
实现定时等待状态。
|
long |
awaitNanos(long nanosTimeout)
实现定时等待状态。
|
void |
awaitUninterruptibly()
实现了不间断的条件等。
|
boolean |
awaitUntil(Date deadline)
实现绝对定时条件等待。
|
protected Collection<Thread> |
getWaitingThreads()
返回包含可能在这种情况下等待的线程的集合。
|
protected int |
getWaitQueueLength()
返回在这种情况下等待的线程数的估计。
|
protected boolean |
hasWaiters()
查询是否有任何线程在这种情况下等待。
|
void |
signal()
移动最长的等待线程,如果有一个存在,从等待队列等待这个条件到拥有锁的等待队列。
|
void |
signalAll()
将所有线程从等待队列中的所有线程移动到拥有锁的等待队列中。
|
public final void signal()
signal 接口
Condition
IllegalMonitorStateException -如果
AbstractQueuedSynchronizer.isHeldExclusively()返回
false
public final void signalAll()
signalAll 接口
Condition
IllegalMonitorStateException -如果
AbstractQueuedSynchronizer.isHeldExclusively()返回
false
public final void awaitUninterruptibly()
AbstractQueuedSynchronizer.getState()锁定状态。AbstractQueuedSynchronizer.release(int)保存状态作为参数,将illegalmonitorstateexception如果失败。AbstractQueuedSynchronizer.acquire(int)。awaitUninterruptibly 接口
Condition
public final void await()
throws InterruptedException
AbstractQueuedSynchronizer.getState()锁定状态。AbstractQueuedSynchronizer.release(int)保存状态作为参数,将illegalmonitorstateexception如果失败。AbstractQueuedSynchronizer.acquire(int)。await 接口
Condition
InterruptedException -如果当前线程被中断(和线程挂起中断的支持)
public final long awaitNanos(long nanosTimeout)
throws InterruptedException
AbstractQueuedSynchronizer.getState()锁定状态。AbstractQueuedSynchronizer.release(int)保存状态作为参数,将illegalmonitorstateexception如果失败。AbstractQueuedSynchronizer.acquire(int)。awaitNanos 接口
Condition
nanosTimeout的最大等待时间,在纳秒
nanosTimeout价值减去时间等候从这个方法返回。一个正值可以用来作为参数,以对这种方法的后续调用,以完成等待所需的时间。一个小于或等于零的值表示没有时间保持。
InterruptedException -如果当前线程被中断(和线程挂起中断的支持)
public final boolean awaitUntil(Date deadline) throws InterruptedException
AbstractQueuedSynchronizer.getState()锁定状态。AbstractQueuedSynchronizer.release(int)保存状态作为参数,将illegalmonitorstateexception如果失败。AbstractQueuedSynchronizer.acquire(int)。awaitUntil 接口
Condition
deadline -等到绝对时间
false如果最后期限已过返回后,其他
true
InterruptedException -如果当前线程被中断(和线程挂起中断的支持)
public final boolean await(long time,
TimeUnit unit)
throws InterruptedException
AbstractQueuedSynchronizer.getState()锁定状态。AbstractQueuedSynchronizer.release(int)保存状态作为参数,将illegalmonitorstateexception如果失败。AbstractQueuedSynchronizer.acquire(int)。await 接口
Condition
time -最大等待时间
unit的
time争论的时间单位
false如果等待的时间检测到才从方法返回,否则
true
InterruptedException -如果当前线程被中断(和线程挂起中断的支持)
protected final boolean hasWaiters()
AbstractQueuedSynchronizer.hasWaiters(ConditionObject)。
true如果有任何等待的线程
IllegalMonitorStateException -如果
AbstractQueuedSynchronizer.isHeldExclusively()返回
false
protected final int getWaitQueueLength()
AbstractQueuedSynchronizer.getWaitQueueLength(ConditionObject)。
IllegalMonitorStateException -如果
AbstractQueuedSynchronizer.isHeldExclusively()返回
false
protected final Collection<Thread> getWaitingThreads()
AbstractQueuedSynchronizer.getWaitingThreads(ConditionObject)。
IllegalMonitorStateException -如果
AbstractQueuedSynchronizer.isHeldExclusively()返回
false
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.