What is the difference between Segment of ConcurrentHashMap and buckets of HashMap theoretically?

余生长醉 提交于 2019-11-30 15:29:34
  1. A bucket is an individual slot in the map's array. This is the same with both HashMap and ConcurrentHashMap. Conceptually, the latter has its array broken into segments (each segment is an array of references), but that's it. Note that the CHM in Java 8 no longer has segments, it's all a single array.

  2. Yes, it's the scheme known as segmented locking. It reduces inter-thread contention, but does not eliminate it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!