AbstractQueuedLongSynchronizer

public abstract class AbstractQueuedLongSynchronizer extends AbstractOwnableSynchronizer
implements Serializable

A version of AbstractQueuedSynchronizer in which synchronization state is maintained as a long. This class has exactly the same structure, properties, and methods as AbstractQueuedSynchronizer with the exception that all state-related parameters and results are defined as long rather than int. This class may be useful when creating synchronizers such as multilevel locks and barriers that require 64 bits of state.

See AbstractQueuedSynchronizer for usage notes and examples.

Nested Class Summary

class AbstractQueuedLongSynchronizer.ConditionObject Condition implementation for a AbstractQueuedLongSynchronizer serving as the basis of a Lock implementation. 

Protected Constructor Summary

AbstractQueuedLongSynchronizer()
Creates a new AbstractQueuedLongSynchronizer instance with initial synchronization state of zero.

Public Method Summary

final void
acquire(long arg)
Acquires in exclusive mode, ignoring interrupts.
final void
acquireInterruptibly(long arg)
Acquires in exclusive mode, aborting if interrupted.
final void
acquireShared(long arg)
Acquires in shared mode, ignoring interrupts.
final void
acquireSharedInterruptibly(long arg)
Acquires in shared mode, aborting if interrupted.
final Collection<Thread>
getExclusiveQueuedThreads()
Returns a collection containing threads that may be waiting to acquire in exclusive mode.
final Thread
getFirstQueuedThread()
Returns the first (longest-waiting) thread in the queue, or null if no threads are currently queued.
final int
getQueueLength()
Returns an estimate of the number of threads waiting to acquire.
final Collection<Thread>
getQueuedThreads()
Returns a collection containing threads that may be waiting to acquire.
final Collection<Thread>
getSharedQueuedThreads()
Returns a collection containing threads that may be waiting to acquire in shared mode.
final int
getWaitQueueLength(AbstractQueuedLongSynchronizer.ConditionObject condition)
Returns an estimate of the number of threads waiting on the given condition associated with this synchronizer.
final Collection<Thread>
getWaitingThreads(AbstractQueuedLongSynchronizer.ConditionObject condition)
Returns a collection containing those threads that may be waiting on the given condition associated with this synchronizer.
final boolean
hasContended()
Queries whether any threads have ever contended to acquire this synchronizer; that is, if an acquire method has ever blocked.
final boolean
hasQueuedPredecessors()
Queries whether any threads have been waiting to acquire longer than the current thread.
final boolean
hasQueuedThreads()
Queries whether any threads are waiting to acquire.
final boolean
hasWaiters(AbstractQueuedLongSynchronizer.ConditionObject condition)
Queries whether any threads are waiting on the given condition associated with this synchronizer.
final boolean
isQueued(Thread thread)
Returns true if the given thread is currently queued.
final boolean
owns(AbstractQueuedLongSynchronizer.ConditionObject condition)
Queries whether the given ConditionObject uses this synchronizer as its lock.
final boolean
release(long arg)
Releases in exclusive mode.
final boolean
releaseShared(long arg)
Releases in shared mode.
String
toString()
Returns a string identifying this synchronizer, as well as its state.
final boolean
tryAcquireNanos(long arg, long nanosTimeout)
Attempts to acquire in exclusive mode, aborting if interrupted, and failing if the given timeout elapses.
final boolean
tryAcquireSharedNanos(long arg, long nanosTimeout)
Attempts to acquire in shared mode, aborting if interrupted, and failing if the given timeout elapses.

Protected Method Summary

final boolean
compareAndSetState(long expect, long update)
Atomically sets synchronization state to the given updated value if the current state value equals the expected value.
final long
getState()
Returns the current value of synchronization state.
boolean
isHeldExclusively()
Returns true if synchronization is held exclusively with respect to the current (calling) thread.
final void
setState(long newState)
Sets the value of synchronization state.
boolean
tryAcquire(long arg)
Attempts to acquire in exclusive mode.
long
tryAcquireShared(long arg)
Attempts to acquire in shared mode.
boolean
tryRelease(long arg)
Attempts to set the state to reflect a release in exclusive mode.
boolean
tryReleaseShared(long arg)
Attempts to set the state to reflect a release in shared mode.

Inherited Method Summary