org.jboss.cache.util.concurrent
Class ReclosableLatch
java.lang.Object
java.util.concurrent.locks.AbstractQueuedSynchronizer
org.jboss.cache.util.concurrent.ReclosableLatch
- All Implemented Interfaces:
- Serializable
public class ReclosableLatch
- extends AbstractQueuedSynchronizer
This latch allows you to set a default state (open or closed), and repeatedly open or close
the latch and have threads wait on it.
This is a better impl of the old org.jboss.cache.util.ThreadGate (which doesn't exist anymore), that uses an
AbstractQueuedSynchronizer
while ThreadGate used to use explicit Lock
objects.
- Since:
- 3.0
- Author:
- Manik Surtani (manik AT jboss DOT org)
- See Also:
- Serialized Form
Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer |
acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease |
ReclosableLatch
public ReclosableLatch()
ReclosableLatch
public ReclosableLatch(boolean defaultOpen)
tryAcquireShared
public final int tryAcquireShared(int ignored)
- Overrides:
tryAcquireShared
in class AbstractQueuedSynchronizer
tryReleaseShared
public final boolean tryReleaseShared(int state)
- Overrides:
tryReleaseShared
in class AbstractQueuedSynchronizer
open
public final void open()
close
public final void close()
await
public final void await()
throws InterruptedException
- Throws:
InterruptedException
await
public final boolean await(long time,
TimeUnit unit)
throws InterruptedException
- Throws:
InterruptedException
Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.