public class SemaphoreLock extends Object implements 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(Semaphore semaphore) |
| Modifier and Type | Method and Description |
|---|---|
void |
lock() |
void |
lockInterruptibly() |
Condition |
newCondition() |
boolean |
tryLock() |
boolean |
tryLock(long time,
TimeUnit unit) |
void |
unlock() |
public SemaphoreLock(Semaphore semaphore)
public void lock()
lock in interface LockLock.lock()public void lockInterruptibly() throws InterruptedException
lockInterruptibly in interface LockInterruptedExceptionLock.lockInterruptibly()public Condition newCondition()
newCondition in interface LockLock.newCondition()public boolean tryLock()
tryLock in interface LockLock.tryLock()public boolean tryLock(long time, TimeUnit unit) throws InterruptedException
tryLock in interface LockInterruptedExceptionLock.tryLock(long, java.util.concurrent.TimeUnit)public void unlock()
unlock in interface LockLock.unlock()Copyright © 2004–2014 Paul Ferraro. All rights reserved.