• HashMap与HashTable区别
  • HashMap与ConcurrentHashMap区别

1.HashMap与HashTable的区别

  • HashMap线程不安全,HashTable线程安全
  • HashMap和HashTable都是采用数组和链表的方式存储数据
  • HashMap允许键和值都为空,HashTable则不行
  • HashTable采用同步机制,用sychronized锁住整个对象,当并发量大时性能极具下降,因此HashTable性能不如HashMap
  • HashMap扩容时采用capcity*2,而HashTable则是capcity+1,HashMap采用hash法和位运算取散列值,更均匀
  • HashTable已淘汰

2.HashMap与ConcurrentHashMap区别

  • ConcurrentHashMap采用分割技术(Segment),把一个大的Map分割成N个HashTable,在对每个Segment用lock锁,只是锁定Map一部分,因此性能好
  • HashMap键值允许为空,而ConcurrentHashMap都不允许为空

参考资料:http://blog.csdn.net/seu_calvin/article/details/52653711

相关文章:

  • 2022-01-23
  • 2021-09-16
  • 2021-12-07
  • 2021-04-11
  • 2021-09-11
  • 2021-11-24
  • 2021-06-03
猜你喜欢
  • 2021-10-20
  • 2022-01-06
  • 2021-08-03
  • 2021-07-12
  • 2021-08-21
  • 2022-12-23
  • 2021-10-15
相关资源
相似解决方案