ConcurrentHashMap vs Synchronized HashMap

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

    A simple performance test for ConcurrentHashMap vs Synchronized HashMap . The test flow is calling put in one thread and calling get in three threads on Map concurrently. As @trshiv said, ConcurrentHashMap has higher throughput and speed for whose reading operation without lock. The result is when operation times is over 10^7, ConcurrentHashMap is 2x faster than Synchronized HashMap.

提交回复
热议问题