本文介紹了ConcurrentHashMap 中的分割的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我是 Java 世界的新手,我在探索 ConcurrentHashMap API 時發現了這一點:
I am a newbie to the world of Java and I was exploring the ConcurrentHashMap API in which I discovered this:
static final int DEFAULT_INITIAL_CAPACITY = 16;
static final float DEFAULT_LOAD_FACTOR = 0.75F;
static final int DEFAULT_CONCURRENCY_LEVEL = 16;
static final int MAXIMUM_CAPACITY = 1073741824;
static final int MAX_SEGMENTS = 65536;
static final int RETRIES_BEFORE_LOCK = 2;
final Segment<K, V>[] segments;
final Segment<K, V> segmentFor(int paramInt)
{
return this.segments[(paramInt >>> this.segmentShift & this.segmentMask)];
}
ConcurrentHashMap 中分割的基本原理是什么,為什么要使用它?請就細分概念提供更多建議.
What are the fundamentals of segmentation in ConcurrentHashMap and why it is used? Please advise more on the segmentation concept.
推薦答案
并發散列映射將其內容劃分為段,以減少寫鎖爭用.
The concurrent hash map divides its contents into segments, to reduce writer lock contention.
concurrencyLevel
參數定義段數.默認為 16.
The concurrencyLevel
parameter defines the number of segments. It's 16 by default.
這篇關于ConcurrentHashMap 中的分割的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!