ConcurrentHashMap vs Synchronized HashMap

后端 未结 12 2382
北海茫月
北海茫月 2020-11-27 09:50

What is the difference between using the wrapper class, SynchronizedMap, on a HashMap and ConcurrentHashMap?

Is it just bein

12条回答
  •  醉话见心
    2020-11-27 10:03

    ConcurrentHashMap :

    1)Both maps are thread-safe implementations of the Map interface.

    2)ConcurrentHashMap is implemented for higher throughput in cases where high concurrency is expected.

    3) There is no locking in object level.

    Synchronized Hash Map:

    1) Each method is synchronized using an object level lock.

提交回复
热议问题