TKey
- - type of the key.TValue
- - type of the value.public class BlockingHashMap<TKey,TValue>
extends java.lang.Object
Keys are stored as weak references, and will be automatically removed once they've all been dereferenced.
Constructor and Description |
---|
BlockingHashMap()
Initialize a new map.
|
Modifier and Type | Method and Description |
---|---|
static <TKey,TValue> |
create()
Initialize a new map.
|
TValue |
get(TKey key)
Waits until a value has been associated with the given key, and then retrieves that value.
|
TValue |
get(TKey key,
long timeout,
java.util.concurrent.TimeUnit unit)
Waits until a value has been associated with the given key, and then retrieves that value.
|
java.util.Set<TKey> |
keys() |
TValue |
put(TKey key,
TValue value)
Associate a given key with the given value.
|
int |
size() |
java.util.Collection<TValue> |
values() |
public static <TKey,TValue> BlockingHashMap<TKey,TValue> create()
public TValue get(TKey key) throws java.lang.InterruptedException
key
- - the key whose associated value is to be returnedjava.lang.InterruptedException
- If the current thread got interrupted while waiting.public TValue get(TKey key, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
key
- - the key whose associated value is to be returnedtimeout
- - the amount of time to wait until an association has been made.unit
- - unit of timeout.java.lang.InterruptedException
- If the current thread got interrupted while waiting.public TValue put(TKey key, TValue value)
Wakes up any blocking getters on this specific key.
key
- - the key to associate.value
- - the value.public int size()
public java.util.Collection<TValue> values()
public java.util.Set<TKey> keys()