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 Lock
Lock.lock()
public void lockInterruptibly() throws InterruptedException
lockInterruptibly
in interface Lock
InterruptedException
Lock.lockInterruptibly()
public Condition newCondition()
newCondition
in interface Lock
Lock.newCondition()
public boolean tryLock()
tryLock
in interface Lock
Lock.tryLock()
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException
tryLock
in interface Lock
InterruptedException
Lock.tryLock(long, java.util.concurrent.TimeUnit)
public void unlock()
unlock
in interface Lock
Lock.unlock()
Copyright © 2004–2014 Paul Ferraro. All rights reserved.