public final class ConcurrentMaps extends Object
ConcurrentMap interface.| Modifier and Type | Field and Description |
|---|---|
protected static int |
SPIN_THRESHOLD_IN_MILLIS
The amount of time to spin before backing off and waiting.
|
| Constructor and Description |
|---|
ConcurrentMaps() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> V |
putAndSignal(ConcurrentMap<K,V> map,
K key,
V value)
Place the
key in the map and associated it with the
value. |
static <K,V> V |
waitAndRemove(ConcurrentMap<K,V> map,
K key)
Execute the
Map.remove(Object) method while causing the
current thread to block, if necessary, until the key is in the
map and associated with a non-null value. |
protected static int SPIN_THRESHOLD_IN_MILLIS
public static <K,V> V putAndSignal(ConcurrentMap<K,V> map, K key, V value)
key in the map and associated it with the
value. Finally, send a signal to threads waiting on
a signal to remove the
key.map - the map into which the key and
value are placedkey - the key to associate with the valuevalue - the value to associate with the keykey in the
mappublic static <K,V> V waitAndRemove(ConcurrentMap<K,V> map, K key)
Map.remove(Object) method while causing the
current thread to block, if necessary, until the key is in the
map and associated with a non-null value.
This method should only be used in conjunction with the
putAndSignal(ConcurrentMap, Object, Object) method.
map - the map from which the key is
removedkey - the key to remove from the mapnon-null value that was associated with a key
and is therefore removed.