ConcurrentHashMap与一般HashMap的区别_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > ConcurrentHashMap与一般HashMap的区别

ConcurrentHashMap与一般HashMap的区别

 2015/1/11 13:04:07  lisj10659  程序员俱乐部  我要评论(0)
  • 摘要:官方文档描述如下:Ahashtablesupportingfullconcurrencyofretrievalsandadjustableexpectedconcurrencyforupdates.ThisclassobeysthesamefunctionalspecificationasHashtable,andincludesversionsofmethodscorrespondingtoeachmethodofHashtable.However
  • 标签:has Map Hash 区别
官方文档描述如下:A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. This class obeys the same functional specification as Hashtable, and includes versions of methods corresponding to each method of Hashtable. However, even though all operations are thread-safe, retrieval operations do not entail locking, and there is not any support for locking the entire table in a way that prevents all access. This class is fully interoperable with Hashtable in programs that rely on its thread safety but not on its synchronization details. 通俗来说就是:有操作都是线程安全的,但检索操作不必锁定,并且不 支持以某种防止所有访问的方式锁定整个表。此类可以通过程序完全与 Hashtable 进行互操作,这取决于其线程安全,而与其同步细节无关,它的锁机制采用1.5的Lock,而不像HashTable synchronized,性能上好多了,之前用到HashMap而现在有线程安全的需求这是个不错的方案具体可以参考http://blog.csdn.net/xuefeng0707/article/details/40834595

发表评论
用户名: 匿名