1,jdk6 中的ConcurrentHashMap
ConcurrentHashMap 是并發(fā)場(chǎng)景下使用的hashmap奢人,有很高的并發(fā)訪問(wèn)性能谓媒,內(nèi)部主要有兩個(gè)內(nèi)部靜態(tài)類,一個(gè)是HashEntry 類何乎,另外一個(gè)是Segment 類句惯。
HashEntry 用來(lái)封裝散列映射表中的鍵值對(duì),并且是一個(gè)鏈表結(jié)構(gòu)
Segment 類中有HashEntry 的數(shù)組支救,相當(dāng)于一個(gè)桶抢野,總體圖類似于下面
一個(gè)ConcurrentHashMap 有多個(gè)桶Segment,每個(gè)桶中有多個(gè)HashEntrytable
private static final long serialVersionUID = 7249069246763182397L;
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 int segmentMask;
final int segmentShift;
final ConcurrentHashMap.Segment<K, V>[] segments;
transient Set<K> keySet;
transient Set<Entry<K, V>> entrySet;
transient Collection<V> values;