久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

ConcurrentHashMap的Segment和HashMap的bucket在理論上有什

What is the difference between Segment of ConcurrentHashMap and buckets of HashMap theoretically?(ConcurrentHashMap的Segment和HashMap的bucket在理論上有什么區別?)
本文介紹了ConcurrentHashMap的Segment和HashMap的bucket在理論上有什么區別?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我了解在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.

  1. 我能否將這個概念與 ConcurrentHashMap 的概念相關聯,但不是 Buckets,而是有各個線程在其上具有鎖的 Segment.而不是 Entries,有 HashEntry(ies).以類似的方式創建一個鏈表,如果插入的鍵值對不同,則根據鍵的 equals() 將其放在鏈表的末尾.
  2. 我這樣說對嗎:CHM 的 put 是不同步的,因此任何線程都可以訪問這個方法,這個 put 方法計算傳遞給它的鍵的哈希值并獲取段索引(有點像桶).然后僅針對該段,它調用 put 方法.現在在 Segment 下, put 方法指定將有一個 lock(),因此只有一個線程可以更改特定段中的數據,因此得出結論,如果并發級別為 16,則應有 16 個線程,因此這些線程將是一次只能PUT值一個段.

推薦答案

  1. 桶是地圖數組中的一個單獨的槽.這對于 HashMapConcurrentHashMap 都是一樣的.從概念上講,后者將其數組分解為段(每個段都是引用數組),僅此而已.請注意,Java 8 中的 CHM 不再有段,而是一個數組.

  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.

是的,這就是稱為分段鎖定的方案.它減少了線程間爭用,但并沒有消除它.

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

這篇關于ConcurrentHashMap的Segment和HashMap的bucket在理論上有什么區別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Convert List of Strings into Map using Java-8 Streams API(使用 Java-8 Streams API 將字符串列表轉換為 Map)
Getting data from JSON(從 JSON 獲取數據)
java linkedhashmap iteration(javalinkedhashmap迭代)
Converting a list of objects to Map(將對象列表轉換為 Map)
Create a HashMap with a fixed Key corresponding to a HashSet. point of departure(用一個固定的Key對應一個HashSet創建一個HashMap.出發點)
HttpMessageConverter exception : RestClientException: Could not write request: no suitable HttpMessageConverter found(HttpMessageConverter 異常:RestClientException:無法寫入請求:找不到合適的 HttpMessageConverter) - IT屋-程序員
主站蜘蛛池模板: 亚洲高清视频一区二区 | 91看片免费 | 亚洲欧美精品久久 | av中文字幕在线播放 | 99自拍视频| 欧美综合精品 | 亚洲国产免费 | 亚洲精品中文字幕中文字幕 | 99精品在线观看 | 黄频免费| 美女视频网站久久 | 国产成人艳妇aa视频在线 | 欧美精品久久 | 日本一二区视频 | 91av视频| 亚洲国产欧美国产综合一区 | 天天天天操| 亚洲国产成人精品久久久国产成人一区 | 欧美日韩综合一区 | 一级黄色片免费在线观看 | 粉嫩粉嫩芽的虎白女18在线视频 | 国产午夜在线 | 成人在线免费观看视频 | 日韩成人在线看 | 久久精品电影 | 五月婷婷婷 | 波多野结衣中文字幕一区二区三区 | 麻豆一区二区三区 | 亚洲国产aⅴ成人精品无吗 欧美激情欧美激情在线五月 | 久久精品亚洲精品国产欧美 | 久热国产精品 | 看一级黄色毛片 | 亚洲精品一区二区三区 | 91视频.com | 91视频88av | 亚洲一区二区三区视频免费观看 | 91久久国产综合久久91精品网站 | 欧美亚洲国产日韩 | 精品久久久999 | 国产一区二区电影 | 日韩三区 |