ConcurrentHashMap vs Synchronized HashMap

后端 未结 12 2319
北海茫月
北海茫月 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:05

    The short answer:

    Both maps are thread-safe implementations of the Map interface. ConcurrentHashMap is implemented for higher throughput in cases where high concurrency is expected.

    Brian Goetz's article on the idea behind ConcurrentHashMap is a very good read. Highly recommended.

提交回复
热议问题