ConditionObject
open class ConditionObject : Condition, Serializable
kotlin.Any | |
↳ | java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject |
Condition implementation for a AbstractQueuedSynchronizer
serving as the basis of a Lock
implementation.
Method documentation for this class describes mechanics, not behavioral specifications from the point of view of Lock and Condition users. Exported versions of this class will in general need to be accompanied by documentation describing condition semantics that rely on those of the associated AbstractQueuedSynchronizer
.
This class is Serializable, but all fields are transient, so deserialized conditions have no waiters.
Summary
Public constructors | |
---|---|
Creates a new |
Public methods | |
---|---|
Unit |
await() Implements interruptible condition wait. |
Boolean |
Implements timed condition wait. |
Long |
awaitNanos(nanosTimeout: Long) Implements timed condition wait. |
Unit |
Implements uninterruptible condition wait. |
Boolean |
awaitUntil(deadline: Date!) Implements absolute timed condition wait. |
Unit |
signal() Moves the longest-waiting thread, if one exists, from the wait queue for this condition to the wait queue for the owning lock. |
Unit |
Moves all threads from the wait queue for this condition to the wait queue for the owning lock. |
Protected methods | |
---|---|
Int |
Returns an estimate of the number of threads waiting on this condition. |
MutableCollection<Thread!>! |
Returns a collection containing those threads that may be waiting on this Condition. |
Boolean |
Queries whether any threads are waiting on this condition. |
Public constructors
Public methods
await
fun await(): Unit
Implements interruptible condition wait.
- If current thread is interrupted, throw InterruptedException.
- Save lock state returned by
getState
. - Invoke
release
with saved state as argument, throwing IllegalMonitorStateException if it fails. - Block until signalled or interrupted.
- Reacquire by invoking specialized version of
acquire
with saved state as argument. - If interrupted while blocked in step 4, throw InterruptedException.
Exceptions | |
---|---|
java.lang.InterruptedException |
if the current thread is interrupted (and interruption of thread suspension is supported) |
await
fun await(
time: Long,
unit: TimeUnit!
): Boolean
Implements timed condition wait.
- If current thread is interrupted, throw InterruptedException.
- Save lock state returned by
getState
. - Invoke
release
with saved state as argument, throwing IllegalMonitorStateException if it fails. - Block until signalled, interrupted, or timed out.
- Reacquire by invoking specialized version of
acquire
with saved state as argument. - If interrupted while blocked in step 4, throw InterruptedException.
- If timed out while blocked in step 4, return false, else true.
Parameters | |
---|---|
time |
Long: the maximum time to wait |
unit |
TimeUnit!: the time unit of the time argument |
Return | |
---|---|
Boolean |
false if the waiting time detectably elapsed before return from the method, else true |
Exceptions | |
---|---|
java.lang.InterruptedException |
if the current thread is interrupted (and interruption of thread suspension is supported) |
awaitNanos
fun awaitNanos(nanosTimeout: Long): Long
Implements timed condition wait.
- If current thread is interrupted, throw InterruptedException.
- Save lock state returned by
getState
. - Invoke
release
with saved state as argument, throwing IllegalMonitorStateException if it fails. - Block until signalled, interrupted, or timed out.
- Reacquire by invoking specialized version of
acquire
with saved state as argument. - If interrupted while blocked in step 4, throw InterruptedException.
Parameters | |
---|---|
nanosTimeout |
Long: the maximum time to wait, in nanoseconds |
Return | |
---|---|
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. |
Exceptions | |
---|---|
java.lang.InterruptedException |
if the current thread is interrupted (and interruption of thread suspension is supported) |
awaitUninterruptibly
fun awaitUninterruptibly(): Unit
Implements uninterruptible condition wait.
awaitUntil
fun awaitUntil(deadline: Date!): Boolean
Implements absolute timed condition wait.
- If current thread is interrupted, throw InterruptedException.
- Save lock state returned by
getState
. - Invoke
release
with saved state as argument, throwing IllegalMonitorStateException if it fails. - Block until signalled, interrupted, or timed out.
- Reacquire by invoking specialized version of
acquire
with saved state as argument. - If interrupted while blocked in step 4, throw InterruptedException.
- If timed out while blocked in step 4, return false, else true.
Parameters | |
---|---|
deadline |
Date!: the absolute time to wait until |
Return | |
---|---|
Boolean |
false if the deadline has elapsed upon return, else true |
Exceptions | |
---|---|
java.lang.InterruptedException |
if the current thread is interrupted (and interruption of thread suspension is supported) |
signal
fun signal(): Unit
Moves the longest-waiting thread, if one exists, from the wait queue for this condition to the wait queue for the owning lock.
Exceptions | |
---|---|
java.lang.IllegalMonitorStateException |
if isHeldExclusively returns false |
signalAll
fun signalAll(): Unit
Moves all threads from the wait queue for this condition to the wait queue for the owning lock.
Exceptions | |
---|---|
java.lang.IllegalMonitorStateException |
if isHeldExclusively returns false |
Protected methods
getWaitQueueLength
protected fun getWaitQueueLength(): Int
Returns an estimate of the number of threads waiting on this condition. Implements AbstractQueuedSynchronizer.getWaitQueueLength(ConditionObject)
.
Return | |
---|---|
Int |
the estimated number of waiting threads |
Exceptions | |
---|---|
java.lang.IllegalMonitorStateException |
if isHeldExclusively returns false |
getWaitingThreads
protected fun getWaitingThreads(): MutableCollection<Thread!>!
Returns a collection containing those threads that may be waiting on this Condition. Implements AbstractQueuedSynchronizer.getWaitingThreads(ConditionObject)
.
Return | |
---|---|
MutableCollection<Thread!>! |
the collection of threads |
Exceptions | |
---|---|
java.lang.IllegalMonitorStateException |
if isHeldExclusively returns false |
hasWaiters
protected fun hasWaiters(): Boolean
Queries whether any threads are waiting on this condition. Implements AbstractQueuedSynchronizer.hasWaiters(ConditionObject)
.
Return | |
---|---|
Boolean |
true if there are any waiting threads |
Exceptions | |
---|---|
java.lang.IllegalMonitorStateException |
if isHeldExclusively returns false |