我了解在HashMap中,条目(Key,Value)是根据hash(Key.hashCode)放在桶中的-->表示桶位置的索引.如果条目已经放置在该位置,则会创建一个链表,并且新条目(如果它具有不同的键 --> 通过 equals() 方法)放置在链表的开头.
I understand that in HashMap, the entries (Key, Value) are placed in buckets based on hash(Key.hashCode)--> The index that denotes the bucket location. In case an entry is already placed at that location, there is a linked list created and the new entry (if it has different key --> via equals() method) is placed at the beginning of the linked list.
桶是地图数组中的一个单独的槽.这对于 HashMap 和 ConcurrentHashMap 都是一样的.从概念上讲,后者将其数组分解为段(每个段都是引用数组),仅此而已.请注意,Java 8 中的 CHM 不再有段,而是一个数组.
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.
是的,这就是称为分段锁定的方案.它减少了线程间争用,但并没有消除它.
Yes, it's the scheme known as segmented locking. It reduces inter-thread contention, but does not eliminate it.
这篇关于ConcurrentHashMap的Segment和HashMap的bucket在理论上有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
使用 Java-8 Streams API 将字符串列表转换为 MapConvert List of Strings into Map using Java-8 Streams API(使用 Java-8 Streams API 将字符串列表转换为 Map)
从 JSON 获取数据Getting data from JSON(从 JSON 获取数据)
javalinkedhashmap迭代java linkedhashmap iteration(javalinkedhashmap迭代)
将对象列表转换为 MapConverting a list of objects to Map(将对象列表转换为 Map)
用一个固定的Key对应一个HashSet创建一个HashMap.出Create a HashMap with a fixed Key corresponding to a HashSet. point of departure(用一个固定的Key对应一个HashSet创建一个HashMap.出发点)
HttpMessageConverter 异常:RestClientException:无法写入请HttpMessageConverter exception : RestClientException: Could not write request: no suitable HttpMessageConverter found(HttpMessageConverter 异常:RestC