`
lisj10659
  • 浏览: 5428 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

ConcurrentHashMap与一般HashMap的区别

阅读更多
官方文档描述如下: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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics