V
- the value type of the latch@ThreadSafe public class HeldValueLatch<V> extends Object
Modifier and Type | Method and Description |
---|---|
V |
await()
Acquires the value held be the latch, or blocks to wait for the value to become available
|
V |
countDown(V value)
Sets the value in the latch
|
static <V> HeldValueLatch<V> |
create()
Creates a new latch that can hold a value
|
V |
get()
Acquires the value without waiting for the latch to be counted down
|
boolean |
hasValue()
Inspects the latch to find of the object has been counted down
|
public static <V> HeldValueLatch<V> create()
V
- the type of the valuepublic V countDown(V value)
The effects of setting this only once is unspecified
This is unsynchronized because all actions prior to counting down happens-before another thread awaits the value
value
- the value to set to the latchpublic boolean hasValue()
true
if the value has been setpublic V await() throws InterruptedException
InterruptedException
- if the operation was interrupted while blockedCopyright © 2016. All rights reserved.