![]() |
VOOZH | about |
ConcurrentHashMap class obeys the same functional specification as HashTable and includes all the versions of methods corresponding to each method of a HashTable. A HashTable supports the full concurrency of retrievals and adjustable concurrency for updates. All the operations of ConcurrentHashMap are thread-safe but the retrieval operations do not entail locking i.e. it does not support locking the entire table in a way that prevents all access. This API is fully interoperable to the HashTable in the programs. It is present in java.util.concurrent package.
ConcurrentHashMap extends AbstractMap<K,V> and Object classes. This API does not allow null to be used as a key or value and it is a member of Java Collections Framework.
Type Parameters:
All implemented interfaces:
Serializable, ConcurrentMap<K,V>, Map<K,V>
Syntax:
public class ConcurrentHashMap<K,V> extends AbstractMap<K,V> implements ConcurrentMap<K,V>, Serializable
Constructors:
Code:
The Keys of the ConcurrentHashMap is 1 2 3 4 The values of the ConcurrentHashMap is Amit Ankush Akshat Tarun The entry set of the ConcurrentHashMap is 1=Amit 2=Ankush 3=Akshat 4=Tarun The ConcurrentHashMap contains Key 3 :true The ConcurrentHashMap contains Tarun:true Put the key 10 with value Shikha if not associated : null Replace key 3 oldvalue of Akshat and newvalue Pari :true The Size of the ConcurrentHashMap is 5 The ConcurrentHashMap is empty