ConcurrentHashMap和Collections.synchronizedMap(Map)有什么区别?

问题:

I have a Map which is to be modified by several threads concurrently. 我有一个地图,该地图将同时被多个线程修改。 html

There seem to be three different synchronized Map implementations in the Java API: Java API中彷佛有三种不一样的同步Map实现: java

  • Hashtable
  • Collections.synchronizedMap(Map)
  • ConcurrentHashMap

From what I understand, Hashtable is an old implementation (extending the obsolete Dictionary class), which has been adapted later to fit the Map interface. 据我了解, Hashtable是一个旧的实现(扩展了过期的Dictionary类),后来对其进行了调整以适合Map接口。 While it is synchronized, it seems to have serious scalability issues and is discouraged for new projects. 虽然它同步的,但彷佛存在严重的可伸缩性问题 ,所以不建议用于新项目。 spa

But what about the other two? 可是其余两个呢? What are the differences between Maps returned by Collections.synchronizedMap(Map) and ConcurrentHashMap s? Collections.synchronizedMap(Map)ConcurrentHashMap返回的Collections.synchronizedMap(Map)之间有什么区别? Which one fits which situation? 哪种适合哪一种状况? .net


解决方案:

参考一: https://stackoom.com/question/28q0/ConcurrentHashMap和Collections-synchronizedMap-Map-有什么区别
参考二: https://oldbug.net/q/28q0/What-s-the-difference-between-ConcurrentHashMap-and-Collections-synchronizedMap-Map
相关文章
相关标签/搜索