Spin locks do not support conditions, and they do not support timed waiting. Normally only the uninterruptible lock,
tryLock, and unlock methods should be used to control the lock.
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private int | |
| private volatile Thread | |
| private static final long | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SpinLock(final int
the spin limit to use for this instance spinLimit)Construct a new instance with the given spin limit. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true; the lock is fairImplements org. |
| public boolean | Returns: true if the lock is held by the calling thread, false otherwiseImplements org. |
| public boolean | Returns: true if the lock is held by any thread, false otherwiseImplements org. |
| public void | lock()
Implements java. |
| public void | lockInterruptibly()
Implements java. |
| public Condition | |
| public boolean | Returns: true if the lock was acquired, false otherwiseImplements java. |
| public boolean | Returns: nothingignored time, final TimeUnit ignored unit)Implements java. |
| public void |
| defaultSpinLimit | back to summary |
|---|---|
| private static final int defaultSpinLimit | |
| level | back to summary |
|---|---|
| private int level | |
| owner | back to summary |
|---|---|
private volatile Thread owner
| |
| ownerOffset | back to summary |
|---|---|
| private static final long ownerOffset | |
| spinLimit | back to summary |
|---|---|
| private final int spinLimit | |
| SpinLock | back to summary |
|---|---|
| public SpinLock() Construct a new instance. | |
| SpinLock | back to summary |
|---|---|
| public SpinLock(final int spinLimit) Construct a new instance with the given spin limit.
| |
| isFair | back to summary |
|---|---|
| public boolean isFair() Implements org. Determine if this lock is fair.
| |
| isHeldByCurrentThread | back to summary |
|---|---|
| public boolean isHeldByCurrentThread() Implements org. Determine if this spin lock is held by the calling thread. Useful for assertions.
| |
| isLocked | back to summary |
|---|---|
| public boolean isLocked() Implements org. Determine if this spin lock is held. Useful for assertions.
| |
| lock | back to summary |
|---|---|
| public void lock() Implements java. Acquire the lock by spinning until it is held. | |
| lockInterruptibly | back to summary |
|---|---|
| public void lockInterruptibly() throws InterruptedException Implements java. Acquire the lock by spinning until it is held or the thread is interrupted.
| |
| newCondition | back to summary |
|---|---|
| public Condition newCondition() throws UnsupportedOperationException Implements java. Unsupported.
| |
| tryLock | back to summary |
|---|---|
| public boolean tryLock() Implements java. Try to acquire the lock, returning immediately whether or not the lock was acquired.
| |
| tryLock | back to summary |
|---|---|
| public boolean tryLock(final long time, final TimeUnit unit) throws UnsupportedOperationException Implements java. Unsupported.
| |
| unlock | back to summary |
|---|---|
| public void unlock() Implements java. Release the lock.
| |