org.infinispan.util.concurrent
Class WatchableValue
java.lang.Object
java.util.concurrent.locks.AbstractQueuedSynchronizer
org.infinispan.util.concurrent.WatchableValue
- All Implemented Interfaces:
- Serializable
public class WatchableValue
- extends AbstractQueuedSynchronizer
Allows threads to watch a variable and be notified when the state of the variable reaches a specific value.
E.g.,
ValueNotifier v = new ValueNotifier(0);
Thread1:
v.setValue(10);
Thread2:
v.awaitValue(5); // will block until another thread sets the value to 5
- Since:
- 4.0
- Author:
- Manik Surtani
- 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 |
WatchableValue
public WatchableValue(int initValue)
tryAcquireShared
public final int tryAcquireShared(int value)
- Overrides:
tryAcquireShared
in class AbstractQueuedSynchronizer
tryReleaseShared
public final boolean tryReleaseShared(int state)
- Overrides:
tryReleaseShared
in class AbstractQueuedSynchronizer
setValue
public final void setValue(int value)
awaitValue
public final void awaitValue(int value)
throws InterruptedException
- Throws:
InterruptedException
awaitValue
public final boolean awaitValue(int value,
long time,
TimeUnit unit)
throws InterruptedException
- Throws:
InterruptedException
getValue
public int getValue()
Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.