Package com.yahoo.concurrent
Class CopyOnWriteHashMap<K,V>
- java.lang.Object
-
- com.yahoo.concurrent.CopyOnWriteHashMap<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
public class CopyOnWriteHashMap<K,V> extends java.lang.Object implements java.util.Map<K,V>
This is a thread hash map for small collections that are stable once built. Until it is stable there will be a race among all threads missing something in the map. They will then clone the map add the missing stuff and then put it back as active again. Here are no locks, but the cost is that inserts will happen a lot more than necessary. The map reference is volatile, but on most multicpu machines that has no cost unless modified.- Author:
- baldersheim
-
-
Constructor Summary
Constructors Constructor Description CopyOnWriteHashMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
V
get(java.lang.Object key)
boolean
isEmpty()
java.util.Set<K>
keySet()
V
put(K key, V value)
void
putAll(java.util.Map<? extends K,? extends V> m)
V
remove(java.lang.Object key)
int
size()
java.util.Collection<V>
values()
-