ConcurrentHashMap vs. HashMap/SynchronizedMap/HashTable什么时候用ConcurrentHashMap(),读写并发。较HashMap好在其并发性上,读不锁,写的时候锁粒度减小为segment而不是整张表,也就意味着一定程度上可以进行“并发写”。貌似自从有了Concurrent,hashMap就不得宠了。。ConcurrentHashMap,不要轻易用.size(),因为它会锁整张表;ConcurrentHashMap,不要轻易用.remove(),因为它会涉及到hashTable中该entry之前的所有元素都要进行拷贝操作(为什么要拷贝呢? Read More
posted @ 2012-04-20 15:11 技术草根女 Views(2880) Comments(1) Diggs(0) Edit