What's the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)?

前端 未结 19 912
名媛妹妹
名媛妹妹 2020-11-22 11:45

I have a Map which is to be modified by several threads concurrently.

There seem to be three different synchronized Map implementations in the Java API:

    <
相关标签:
19条回答
  • 2020-11-22 12:30

    ConcurrentHashMap is optimized for concurrent access.

    Accesses don't lock the whole map but use a finer grained strategy, which improves scalability. There are also functional enhanvements specifically for concurrent access, e.g. concurrent iterators.

    0 讨论(0)
提交回复
热议问题