java.lang.Object
org.jgroups.util.ReentrantLatch
- public final class ReentrantLatch
- extends java.lang.Object
Enables safely locking and unlocking a shared resource, without blocking the calling threads. Blocking is only done
on the 'passThrough' method.
- Version:
- 1.0
|
Field Summary |
(package private) boolean |
locked
|
|
Method Summary |
void |
lock()
Lock the latch. |
void |
passThrough()
Pass through only when the latch becomes unlocked. |
void |
unlock()
Unlock the latch. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
locked
boolean locked
ReentrantLatch
public ReentrantLatch()
- Create a new unlocked latch.
ReentrantLatch
public ReentrantLatch(boolean locked)
- Create a reentrant latch
lock
public void lock()
- Lock the latch. If it is already locked, this method will have no side effects. This method will not block.
unlock
public void unlock()
- Unlock the latch. If it is already unlocked, this method will have no side effects. This method will not block.
passThrough
public void passThrough()
throws java.lang.InterruptedException
- Pass through only when the latch becomes unlocked. If the latch is locked, wait until someone unlocks it. Does
not lock the latch.