Menu Bar

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Monday, 12 December 2016

What is the difference between HashMap and ConcurrentHashMap In Java ?


Here we list all the differences between HashMap and 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.
HashMap is a fail-fast iterator.
HashMap is useful for single-threaded application.
ConcurrentHashMap is useful for multi-threaded application.

Some Similarities between HashMap and ConcurrentHashMap are as follows :

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.



Share this Blog with yours Friends !!

No comments:

Post a Comment