来自:http://stackoverflow.com/questions/510632/whats-the-difference-between-concurrenthashmap-and-collections-synchronizedmap
http://javarevisited.blogspot.hk/2011/04/difference-between-concurrenthashmap.html
╔═══════════════╦═══════════════════╦═══════════════════╦═════════════════════╗
║ Property ║ HashMap ║ Hashtable ║ ConcurrentHashMap ║
╠═══════════════╬═══════════════════╬═══════════════════╩═════════════════════╣
║ Null ║ allowed ║ not allowed ║
║ values/keys ║ ║ ║
╠═══════════════╬═══════════════════╬═════════════════════════════════════════╣
║Is thread-safe ║ no ║ yes ║
╠═══════════════╬═══════════════════╬═══════════════════╦═════════════════════╣
║ Lock ║ not ║ locks the whole ║ locks the portion ║
║ mechanism ║ applicable ║ map ║ ║
╠═══════════════╬═══════════════════╩═══════════════════╬═════════════════════╣
║ Iterator ║ fail-fast ║ fail-safe ║
╚═══════════════╩═══════════════════════════════════════╩═════════════════════╝What's the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)?
最新推荐文章于 2024-10-11 09:34:09 发布
本文详细比较了HashMap、Hashtable及ConcurrentHashMap三种集合类在Java中使用时的特性差异,包括是否允许null键值、线程安全性、锁机制以及迭代器的安全性等方面。
2124

被折叠的 条评论
为什么被折叠?



