ConcurrentHashMapK,V


ConcurrentHashMap<K,V> java.util.concurrent

Java 5.0 serializable collection

This class is a threadsafe implementation of the java.util.Map interface, and of the atomic operations added by the ConcurrentMap interface. This class is intended as a drop-in replacement for java.util.Hashtable . It is more efficient than that class, however, because it provides threadsafety without using synchronized methods that lock the entire data structure. ConcurrentHashMap allows any number of concurrent read operations without locking. Locking is required for updates to a ConcurrentHashMap , but the internal data structure is segmented so that only the segment being updated is locked, and reads and writes can proceed concurrently in other segments. You can specify the number of internal segments with the concurrencyLevel argument to the constructor. The default is 16. Set this to the approximate number of updater threads you expect to access the data structure. Like Hashtable , ConcurrentHashMap does not allow null keys or values. (Note that this differs from the behavior of java.util.HashMap .)

Figure 16-75. java.util.concurrent.ConcurrentHashMap<K,V>

 public class  ConcurrentHashMap<K,V>  extends java.util.AbstractMap<K,V>  implements ConcurrentMap<K,V>, Serializable {  // Public Constructors  public  ConcurrentHashMap  ( );        public  ConcurrentHashMap  (java.util.Map<? extends K,? extends V>  t  );        public  ConcurrentHashMap  (int  initialCapacity  );        public  ConcurrentHashMap  (int  initialCapacity  , float  loadFactor  , int  concurrencyLevel  );  // Public Instance Methods  public boolean  contains  (Object  value  );        public java.util.Enumeration<V>  elements  ( );        public java.util.Enumeration<K>  keys  ( );  // Methods Implementing ConcurrentMap  public V  putIfAbsent  (K  key  , V  value  );        public boolean  remove  (Object  key  , Object  value  );        public V  replace  (K  key  , V  value  );        public boolean  replace  (K  key  , V  oldValue  , V  newValue  );  // Methods Implementing Map  public void  clear  ( );        public boolean  containsKey  (Object  key  );        public boolean  containsValue  (Object  value  );        public java.util.Set<java.util.Map.Entry<K,V>>  entrySet  ( );        public V  get  (Object  key  );        public boolean  isEmpty  ( );  default:true  public java.util.Set<K>  keySet  ( );        public V  put  (K  key  , V  value  );        public void  putAll  (java.util.Map<? extends K,? extends V>  t  );        public V  remove  (Object  key  );        public int  size  ( );        public java.util.Collection<V>  values  ( );   } 



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net