K - V - public class BlockingHashMap<K,V> extends Object implements BlockingMap<K,V>
BlockingMap.
 Note: While it is not actively prevented that more then one thread waits for an entry, it is not guaranteed that all waiting threads will receive the entry once it became available. Other implementations may choose to count the waiting threads and/or to remove an available value after a grace period.
| Constructor and Description | 
|---|
| BlockingHashMap() | 
| BlockingHashMap(ExecutorService executor) | 
| Modifier and Type | Method and Description | 
|---|---|
| Future<V> | asyncPoll(K key,
         long timeout,
         TimeUnit unit)Polls for an entry in a background thread. | 
| Future<V> | asyncTake(K key)Waits for an entry in a background thread. | 
| void | clear()Clears all existing entries. | 
| boolean | containsKey(Object key)Returns  trueif an entry with the given key is available | 
| boolean | containsValue(Object value) | 
| Set<Map.Entry<K,V>> | entrySet() | 
| V | get(Object key)Returns an available entry without removing it from the map | 
| boolean | give(K key,
    V value)Adds an entry only if there's already a consumer waiting for the value. | 
| boolean | isEmpty()Returns true if no entry is available for consumers | 
| Set<K> | keySet()Returns the keys of available entries | 
| V | poll(K key,
    long timeout,
    TimeUnit unit)Waits for the specified amount of time for an entry with the given key
 and returns the associated value. | 
| V | put(K key,
   V value) | 
| void | putAll(Map<? extends K,? extends V> t) | 
| V | remove(Object key)Removes an entry, regardless whether a value has been set or not. | 
| int | size()Returns the number of available values | 
| V | take(K key)Waits for an entry for the given key and returns the associated value. | 
| Collection<V> | values() | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic BlockingHashMap()
public BlockingHashMap(ExecutorService executor)
public Set<K> keySet()
keySet in interface Map<K,V>Map.keySet()public V get(Object key)
get in interface Map<K,V>Map.get(java.lang.Object)public boolean containsKey(Object key)
true if an entry with the given key is availablecontainsKey in interface Map<K,V>Map.containsKey(java.lang.Object)public V put(K key, V value)
put in interface Map<K,V>Map.put(java.lang.Object, java.lang.Object)public boolean give(K key, V value)
BlockingMapgive in interface BlockingMap<K,V>key - key for the entry to be addedvalue - entry to be addedBlockingMap.give(java.lang.Object,
      java.lang.Object)public V take(K key) throws InterruptedException
BlockingMaptake in interface BlockingMap<K,V>key - key for the entryInterruptedExceptionpublic Future<V> asyncTake(K key) throws InterruptedException
BlockingMapasyncTake in interface BlockingMap<K,V>key - key for the entryInterruptedExceptionpublic V poll(K key, long timeout, TimeUnit unit) throws InterruptedException
BlockingMappoll in interface BlockingMap<K,V>key - key for the entrytimeout - timeout before the methods returnsunit - time unit used in conjunction with timoutInterruptedExceptionpublic Future<V> asyncPoll(K key, long timeout, TimeUnit unit)
BlockingMapasyncPoll in interface BlockingMap<K,V>key - key for the entrypublic boolean isEmpty()
isEmpty in interface Map<K,V>Map.isEmpty()public int size()
size in interface Map<K,V>Map.size()public V remove(Object key)
remove in interface Map<K,V>Map.remove(java.lang.Object)public void clear()
clear in interface Map<K,V>Map.clear()public boolean containsValue(Object value)
containsValue in interface Map<K,V>Copyright © 2001–2017 University Health Network. All rights reserved.