Here we list all the differences between HashMap and ConcurrentHashMap in java.
Know Also : What is HashMap In Java ? and What is ConcurrentHashMap In Java ?
HashMap
|
ConcurrentHashMap
|
It is not synchronized.
|
It is synchronized.
|
It is not Thread-safe.
|
It is Thread-safe.
|
Its performance is fast because it is not
thread-safe.
|
Its performance is slow because it is thread-safe.
|
It allows one null key and multiple null values.
|
It doesn’t allow null as a key or as a value.
|
Hashmap can be synchronized by using :
HashMap<String, String> map = new HashMap<>();
Collections.synchronizedMap(map);
|
ConcurrentHashMap is internally synchronized and
it cannot be unsynchronized.
|
ConcurrentHashMap is a fail-safe iterator.
|
|
HashMap is useful for single-threaded application.
|
ConcurrentHashMap is useful for multi-threaded application.
|
HashMap
|
ConcurrentHashMap
|
It extends AbstractMap class.
|
It extends AbstractMap class.
|
It is implementation class of Map Interface.
|
It is implementation class of Map Interface.
|
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.



No comments:
Post a Comment