ConcurrentHashMap vs Synchronized HashMap

后端 未结 12 2383
北海茫月
北海茫月 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 09:55

    Methods on SynchronizedMap hold the lock on the object, whereas in ConcurrentHashMap there's a concept of "lock striping" where locks are held on buckets of the contents instead. Thus improved scalability and performance.

提交回复
热议问题