java.util.concurrent.locks.Lock, ExtendedLockpublic class SpinLock extends java.lang.Object implements ExtendedLock
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.
| Constructor | Description |
|---|---|
SpinLock() |
Construct a new instance.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
isFair() |
Determine if this lock is fair.
|
boolean |
isHeldByCurrentThread() |
Determine if this spin lock is held by the calling thread.
|
boolean |
isLocked() |
Determine if this spin lock is held.
|
void |
lock() |
Acquire the lock by spinning until it is held.
|
void |
lockInterruptibly() |
Acquire the lock by spinning until it is held or the thread is interrupted.
|
java.util.concurrent.locks.Condition |
newCondition() |
Unsupported.
|
boolean |
tryLock() |
Try to acquire the lock, returning immediately whether or not the lock was acquired.
|
boolean |
tryLock(long time,
java.util.concurrent.TimeUnit unit) |
Unsupported.
|
void |
unlock() |
Release the lock.
|
public boolean isLocked()
isLocked in interface ExtendedLocktrue if the lock is held by any thread, false otherwisepublic boolean isHeldByCurrentThread()
isHeldByCurrentThread in interface ExtendedLocktrue if the lock is held by the calling thread, false otherwisepublic boolean isFair()
isFair in interface ExtendedLocktrue; the lock is fairpublic void lock()
lock in interface java.util.concurrent.locks.Lockpublic void lockInterruptibly()
throws java.lang.InterruptedException
lockInterruptibly in interface java.util.concurrent.locks.Lockjava.lang.InterruptedException - if the thread is interrupted before the lock can be acquiredpublic boolean tryLock()
tryLock in interface java.util.concurrent.locks.Locktrue if the lock was acquired, false otherwisepublic void unlock()
unlock in interface java.util.concurrent.locks.Lockjava.lang.IllegalMonitorStateException - if the lock is not held by the current threadpublic boolean tryLock(long time,
java.util.concurrent.TimeUnit unit)
throws java.lang.UnsupportedOperationException
tryLock in interface java.util.concurrent.locks.Locktime - ignoredunit - ignoredjava.lang.UnsupportedOperationException - alwayspublic java.util.concurrent.locks.Condition newCondition()
throws java.lang.UnsupportedOperationException
newCondition in interface java.util.concurrent.locks.Lockjava.lang.UnsupportedOperationException - alwaysCopyright © 2018 JBoss, a division of Red Hat, Inc.