public class SemaphoreLock extends java.lang.Object implements java.util.concurrent.locks.Lock
Lock using a binary semaphore.
Unlike the ReentrantLock this lock can be locked and unlocked by different threads.
Conditions are not supported.| Constructor and Description |
|---|
SemaphoreLock(boolean fair) |
| Modifier and Type | Method and Description |
|---|---|
void |
lock() |
void |
lockInterruptibly() |
java.util.concurrent.locks.Condition |
newCondition() |
boolean |
tryLock() |
boolean |
tryLock(long time,
java.util.concurrent.TimeUnit unit) |
void |
unlock() |
public SemaphoreLock(boolean fair)
public void lock()
lock in interface java.util.concurrent.locks.LockLock.lock()public void lockInterruptibly() throws java.lang.InterruptedException
lockInterruptibly in interface java.util.concurrent.locks.Lockjava.lang.InterruptedExceptionLock.lockInterruptibly()public java.util.concurrent.locks.Condition newCondition()
newCondition in interface java.util.concurrent.locks.LockLock.newCondition()public boolean tryLock()
tryLock in interface java.util.concurrent.locks.LockLock.tryLock()public boolean tryLock(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
tryLock in interface java.util.concurrent.locks.Lockjava.lang.InterruptedExceptionLock.tryLock(long, java.util.concurrent.TimeUnit)public void unlock()
unlock in interface java.util.concurrent.locks.LockLock.unlock()