Difference Between HashMap And ConcurrentHashMap In Java

HashMap_And_ConcurrentHashMap
HashMap :
  • HashMap is non-Synchronized.
  • HashMap is not Thread-safe.
  • HashMap performance is almost high because it is non-synchronized, and threads can perform simultaneously.
  • One Thread is Iterating the HashMap Object, if the other Thread tries to add/modify the contents of the Object then we will get a Run-time exception telling ConcurrentModificationException.
  • HashMap can allow only one null key.
ConcurrentHashMap : 
  • ConcurrentHashMap is Synchronized.
  • ConcurrentHashMap is Thread-safe.
  • ConcurrentHashMap performance is low sometimes because sometimes Threads are required to wait on ConcurrentHashMap.
  • ConcurrentHashMap won’t get any exception while doing any modification at the time of Iteration.
  • If the specified key or value is NULL, it will throw NullPointerException.

API Reference:

final V putVal(K key, V value, boolean onlyIfAbsent) {

if (key == null || value == null) throw new NullPointerException();


  • Please write your valuable comments and feedback below.
Manohar Kota

About Manohar

I, Manohar am the founder and chief editor of ClarifyAll.com. I am working in an IT professional.

View all posts by Manohar →

2 Comments on “Difference Between HashMap And ConcurrentHashMap In Java”

Leave a Reply