越來越多人使用ConcurrentHashMap 替換使用 HashMap止毕,抱著學(xué)習(xí)的態(tài)度看一看源碼,發(fā)現(xiàn)內(nèi)部的實現(xiàn)還是很復(fù)雜的,而且實現(xiàn)很精妙字币,膜拜一下jdk 大神們的智慧。一般我們對于多線程訪問都是敬而遠(yuǎn)之图谷,或者拒之門外翩活,而 Doug Lea 精妙的設(shè)計,反而邀請他們一起來幫忙工作便贵。以下寫一下自己對它的學(xué)習(xí)理解菠镇,有什么不對的地方,還請指正承璃。
Java8-ConcurrentHashMap特點
1.使用了懶加載模式利耍,在第一次put數(shù)據(jù)時,會執(zhí)行初始化操作盔粹,初始化大小默認(rèn)為16
2.使用了數(shù)組+鏈表+紅黑樹的方式存儲數(shù)據(jù)
3.使用了CAS+Synchronize來并發(fā)控制put税稼、remove操作抛寝,對于get 讀操作是沒有添加鎖的
4.支持多線程操作,并發(fā)控制,對于同一桶進(jìn)行操作需要取得鎖才能訪問(put, remove)
下面沖put實現(xiàn)來一一分析一下
put實現(xiàn) --第一部分初始化
/**
* Maps the specified key to the specified value in this table.
* Neither the key nor the value can be null.
*
* <p>The value can be retrieved by calling the {@code get} method
* with a key that is equal to the original key.
*
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
* @return the previous value associated with {@code key}, or
* {@code null} if there was no mapping for {@code key}
* @throws NullPointerException if the specified key or value is null
*/
public V put(K key, V value) {
return putVal(key, value, false);
}
/** Implementation for put and putIfAbsent */
final V putVal(K key, V value, boolean onlyIfAbsent) {
// 不能存儲 key冤竹、value 為 null 數(shù)據(jù)
if (key == null || value == null) throw new NullPointerException();
// 對hash 進(jìn)行再運算,充分利用hashcode惰说,減少碰撞
int hash = spread(key.hashCode());
int binCount = 0;
for (Node<K,V>[] tab = table;;) {
Node<K,V> f; int n, i, fh;
if (tab == null || (n = tab.length) == 0)
// 初始化 hashmap
tab = initTable();
這里需要詳細(xì)說明的是 initTable 方法您觉,初始化哈希表
initTable
/**
* Initializes table, using the size recorded in sizeCtl.
*/
private final Node<K,V>[] initTable() {
Node<K,V>[] tab; int sc;
// 當(dāng)前 哈希表為空的時候 才初始化
while ((tab = table) == null || tab.length == 0) {
// 判斷當(dāng)前有多少個 線程執(zhí)行到這個地方淮摔,
// 如果 sizeCtl < 0 代表當(dāng)前已經(jīng)有線程正在初始化仆百,
if ((sc = sizeCtl) < 0)
Thread.yield(); // lost initialization race; just spin
// 初始時SIZECTL = sc = 0排龄,則返回 true 并設(shè)置 SIZECTL 為 -1竞川,并執(zhí)行 初始化方法
else if (U.compareAndSwapInt(this, SIZECTL, sc, -1)) {
try {
// 再次確認(rèn) 哈希表為空,需要初始化數(shù)據(jù)
if ((tab = table) == null || tab.length == 0) {
// 初始時 sc = 0, 所以初始大小為 DEFAULT_CAPACITY 16
// 如果sc > 0, 說明已經(jīng)初始化了
int n = (sc > 0) ? sc : DEFAULT_CAPACITY;
// 初始化 哈希表
@SuppressWarnings("unchecked")
Node<K,V>[] nt = (Node<K,V>[])new Node<?,?>[n];
table = tab = nt;
// 計算閾值肮街,等效于 n * 0.75
sc = n - (n >>> 2);
}
} finally {
// 設(shè)置閾值
sizeCtl = sc;
}
break;
}
}
return tab;
}
這里需要解釋一下 sizeCtl 默認(rèn)為 0 弟头,-1 代表當(dāng)前正在初始化,或者resizing猖任,-n 代表當(dāng)前有多少個線程正在訪問,已經(jīng)初始化之后 代表著 當(dāng)前哈希表的存儲閾值,用于判斷當(dāng)前是否需要擴(kuò)容瞒斩,另外一個就是compareAndSwapInt裳扯,他有四個參數(shù)饶套,第一參數(shù)就是操作實體儿倒,第二參數(shù)就是偏移量,也可以理解為存儲字段豺型,第三個參數(shù)標(biāo)識判斷 和 第二個字段的內(nèi)容是否相等仲智,如果相等 返回true,并更新第二個參數(shù)所對應(yīng)的值 = 第四個參數(shù)姻氨,如果不相等則返回false钓辆,我們可以發(fā)現(xiàn)只要一個線程可以進(jìn)入初始化操作。
put實現(xiàn) --第二部分桶為空
else if ((f = tabAt(tab, i = (n - 1) & hash)) == null) {
if (casTabAt(tab, i, null,
new Node<K,V>(hash, key, value, null)))
break; // no lock when adding to empty bin
}
當(dāng)桶為空的時候,直接插入節(jié)點數(shù)據(jù)岩馍,這里沒有使用synchronize碉咆,使用了CAS 插入,可以保證只有一個線程修改實體數(shù)據(jù)蛀恩,這里解釋一下
CAS : 無鎖的執(zhí)行者(Compare And Swap)
V表示要更新的變量
E表示預(yù)期值
N表示新值
如果V值等于E值疫铜,則將V的值設(shè)為N。若V值和E值不同双谆,則說明已經(jīng)有其他線程做了更新壳咕,則當(dāng)前線程什么都不做
put實現(xiàn) --第三部分桶的第一個值為 特殊值 MOVED
else if ((fh = f.hash) == MOVED)
tab = helpTransfer(tab, f);
這里我們只大概說一下如果當(dāng)前節(jié)點的hash值 為 MOVED,表示當(dāng)前哈希表正在執(zhí)行resizing操作顽馋,這個時候helpTransfer 意指需要當(dāng)前線程去幫組做resizing操作谓厘,helpTransfer 這個方法比較復(fù)雜我們后面講,
put實現(xiàn) --第四部分桶為正常值
else {
V oldVal = null;
// 對桶 進(jìn)行加鎖處理
synchronized (f) {
// 再次確認(rèn) 桶的數(shù)據(jù)
if (tabAt(tab, i) == f) {
// 節(jié)點為 鏈?zhǔn)酱鎯? if (fh >= 0) {
binCount = 1;
for (Node<K,V> e = f;; ++binCount) {
K ek;
if (e.hash == hash &&
((ek = e.key) == key ||
(ek != null && key.equals(ek)))) {
oldVal = e.val;
if (!onlyIfAbsent)
e.val = value;
break;
}
Node<K,V> pred = e;
// 鏈表末尾插入數(shù)據(jù)
if ((e = e.next) == null) {
pred.next = new Node<K,V>(hash, key,
value, null);
break;
}
}
}
// 紅黑樹存儲結(jié)構(gòu) TreeBin 存儲的是根節(jié)點的信息 hash 值 為 -2
else if (f instanceof TreeBin) {
Node<K,V> p;
binCount = 2;
// 紅黑樹插入數(shù)據(jù)寸谜,這里就不多說了竟稳,不知道的可以先去了解一下
if ((p = ((TreeBin<K,V>)f).putTreeVal(hash, key,
value)) != null) {
oldVal = p.val;
if (!onlyIfAbsent)
p.val = value;
}
}
}
}
// binCount = 0 情況表示,該桶沒有節(jié)點熊痴,插入數(shù)據(jù)
// binCount 他爸!= 0 情況表示,鏈表插入或者 紅黑樹節(jié)點插入 或修改
if (binCount != 0) {
// 當(dāng)鏈表插入數(shù)量 超過 8個時果善,轉(zhuǎn)化成紅黑樹結(jié)構(gòu)存儲
if (binCount >= TREEIFY_THRESHOLD)
// 這里也是紅黑樹轉(zhuǎn)化诊笤,內(nèi)部也是加了 桶 鎖,具體實現(xiàn)就不多說了
treeifyBin(tab, i);
if (oldVal != null)
return oldVal;
break;
}
}
put實現(xiàn) --第五部分修改存儲數(shù)量值
addCount(1L, binCount);
return null;
概述一下put 都做了什么事巾陕,首先判斷一下哈希表有沒有初始化讨跟,沒有初始化時,去初始化操作鄙煤,然后確定桶的位置晾匠,空桶的時候使用CAS 插入節(jié)點數(shù)據(jù),如果是ForwardingNode 節(jié)點馆类,則去協(xié)助擴(kuò)容操作混聊,如果是正常節(jié)點弹谁,則分別取對應(yīng)的鏈表或者紅黑樹中 插入或者更新數(shù)據(jù)乾巧。
注意可以發(fā)現(xiàn)put 里還有兩個非常重要的方法我們沒有分析,一個是helpTransfer(線程幫助擴(kuò)容操作)预愤,一個是addCount(更新存儲數(shù)量值)沟于,我們先從簡單的開始 helpTransfer,這里需要介紹一下ForwardingNode—— A node inserted at head of bins during transfer operations.他是在擴(kuò)容操作中的一個插入在桶頭部的特殊節(jié)點植康,他的含義表明旷太,這個桶已經(jīng)完成了擴(kuò)容操作,但是整個哈希表擴(kuò)容操作還沒有結(jié)束,如果檢測到這種節(jié)點供璧,當(dāng)前線程會被要求一起來完成部分?jǐn)U容操作存崖。
helpTransfer
/**
* Helps transfer if a resize is in progress.
*/
final Node<K,V>[] helpTransfer(Node<K,V>[] tab, Node<K,V> f) {
Node<K,V>[] nextTab; int sc;
// 這里就是檢測,當(dāng)前正在擴(kuò)容操作睡毒,當(dāng)前桶 已完成了擴(kuò)容操作
if (tab != null && (f instanceof ForwardingNode) &&
(nextTab = ((ForwardingNode<K,V>)f).nextTable) != null) {
//返回一個 16 位長度的擴(kuò)容校驗標(biāo)識
int rs = resizeStamp(tab.length);
while (nextTab == nextTable && table == tab &&
(sc = sizeCtl) < 0) {
//sizeCtl 如果處于擴(kuò)容狀態(tài)的話
//高位16 位是數(shù)據(jù)校驗標(biāo)識来惧,地位16 位是當(dāng)前正在擴(kuò)容的線程總數(shù)
//這里判斷校驗標(biāo)識是否相等,如果校驗符不等或者擴(kuò)容操作已經(jīng)完成了演顾,直接退出循環(huán)供搀,不用協(xié)助它們擴(kuò)容了
if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
sc == rs + MAX_RESIZERS || transferIndex <= 0)
break;
//否則調(diào)用 transfer 幫助它們進(jìn)行擴(kuò)容
//sc + 1 標(biāo)識增加了一個線程進(jìn)行擴(kuò)容
if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1)) {
transfer(tab, nextTab);
break;
}
}
return nextTab;
}
return table;
}
接下來就是擴(kuò)容操作了transfer,這個方法內(nèi)容有點多钠至,我們分塊介紹
transfer --第一部分?jǐn)U容準(zhǔn)備
/**
* Moves and/or copies the nodes in each bin to new table. See
* above for explanation.
*/
private final void transfer(Node<K,V>[] tab, Node<K,V>[] nextTab) {
int n = tab.length, stride;
//計算單個線程允許處理的最少table桶首節(jié)點個數(shù)葛虐,不能小于 16
// stride 也叫步幅,是處理的節(jié)點跨度個數(shù)棉钧,最小是 16屿脐,也就是默認(rèn)初始化哈希表的大小
if ((stride = (NCPU > 1) ? (n >>> 3) / NCPU : n) < MIN_TRANSFER_STRIDE)
stride = MIN_TRANSFER_STRIDE; // subdivide range
// 初始化新的哈希表
if (nextTab == null) { // initiating
try {
@SuppressWarnings("unchecked")
Node<K,V>[] nt = (Node<K,V>[])new Node<?,?>[n << 1];
nextTab = nt;
} catch (Throwable ex) { // try to cope with OOME
sizeCtl = Integer.MAX_VALUE;
return;
}
nextTable = nextTab;
//transferIndex 指向最后一個桶,方便從后向前遍歷
transferIndex = n;
}
int nextn = nextTab.length;
// 已完成的 桶的特殊節(jié)點信息
ForwardingNode<K,V> fwd = new ForwardingNode<K,V>(nextTab);
transfer --第二部分?jǐn)U容控制的核心
boolean advance = true;
// 標(biāo)志 當(dāng)前擴(kuò)容操作是否完成后
boolean finishing = false; // to ensure sweep before committing nextTab
//i 指向當(dāng)前桶宪卿,bound 指向當(dāng)前線程需要處理的桶結(jié)點的區(qū)間下限
for (int i = 0, bound = 0;;) {
Node<K,V> f; int fh;
//這個 while 循環(huán)的目的就是通過 --i 遍歷當(dāng)前線程所分配到的桶結(jié)點
//一個桶一個桶的處理
while (advance) {
int nextIndex, nextBound;
// 當(dāng)前正在遷移過程中摄悯,或者已經(jīng)完成了擴(kuò)容
if (--i >= bound || finishing)
advance = false;
//transferIndex <= 0 說明已經(jīng)沒有需要遷移的桶了
else if ((nextIndex = transferIndex) <= 0) {
i = -1;
advance = false;
}
//更新 transferIndex
//為當(dāng)前線程分配任務(wù),處理的桶結(jié)點區(qū)間為(nextBound,nextIndex)
else if (U.compareAndSwapInt
(this, TRANSFERINDEX, nextIndex,
nextBound = (nextIndex > stride ?
nextIndex - stride : 0))) {
bound = nextBound;
i = nextIndex - 1;
advance = false;
}
}
//當(dāng)前線程所有任務(wù)完成
if (i < 0 || i >= n || i + n >= nextn) {
int sc;
// 已完成擴(kuò)容操作愧捕,則設(shè)置新的哈希表連接奢驯,更新sizeCtl 的閾值
if (finishing) {
nextTable = null;
table = nextTab;
sizeCtl = (n << 1) - (n >>> 1);
return;
}
// 更新 SIZECTL 值為 sizeCtl -1,當(dāng)前線程已經(jīng)完成擴(kuò)容操作
if (U.compareAndSwapInt(this, SIZECTL, sc = sizeCtl, sc - 1)) {
// 判斷其他線程是否處理完次绘,如果已處理完瘪阁,其他線程已經(jīng)執(zhí)行過這塊區(qū)域代碼,說明擴(kuò)容操作已經(jīng)完成邮偎,直接返回
if ((sc - 2) != resizeStamp(n) << RESIZE_STAMP_SHIFT)
return;
finishing = advance = true;
i = n; // recheck before commit
}
}
//待遷移桶為空管跺,那么在此位置 CAS 添加 ForwardingNode 結(jié)點標(biāo)識該桶已經(jīng)被處理過了
else if ((f = tabAt(tab, i)) == null)
advance = casTabAt(tab, i, null, fwd);
//如果掃描到 ForwardingNode,說明此桶已經(jīng)被處理過了禾进,跳過即可
else if ((fh = f.hash) == MOVED)
advance = true; // already processed
transfer --第三部分遷移操作
else {
synchronized (f) {
if (tabAt(tab, i) == f) {
Node<K,V> ln, hn;
// 鏈表遷移
if (fh >= 0) {
int runBit = fh & n;
Node<K,V> lastRun = f;
//整個 for 循環(huán)為了找到整個桶中最后連續(xù)的 fh & n 不變的結(jié)點
for (Node<K,V> p = f.next; p != null; p = p.next) {
int b = p.hash & n;
if (b != runBit) {
runBit = b;
lastRun = p;
}
}
if (runBit == 0) {
ln = lastRun;
hn = null;
}
else {
hn = lastRun;
ln = null;
}
//如果fh&n不變的鏈表的runbit都是0豁跑,則nextTab[i]內(nèi)元素ln前逆序,ln及其之后順序
//否則泻云,nextTab[i+n]內(nèi)元素全部相對原table逆序
//這是通過一個節(jié)點一個節(jié)點的往nextTab添加
for (Node<K,V> p = f; p != lastRun; p = p.next) {
int ph = p.hash; K pk = p.key; V pv = p.val;
if ((ph & n) == 0)
ln = new Node<K,V>(ph, pk, pv, ln);
else
hn = new Node<K,V>(ph, pk, pv, hn);
}
//把兩條鏈表整體遷移到nextTab中
setTabAt(nextTab, i, ln);
setTabAt(nextTab, i + n, hn);
// 標(biāo)志著這個桶已經(jīng)完成了遷移
setTabAt(tab, i, fwd);
advance = true;
}
// 紅黑樹 遷移操作
else if (f instanceof TreeBin) {
TreeBin<K,V> t = (TreeBin<K,V>)f;
TreeNode<K,V> lo = null, loTail = null;
TreeNode<K,V> hi = null, hiTail = null;
int lc = 0, hc = 0;
for (Node<K,V> e = t.first; e != null; e = e.next) {
int h = e.hash;
TreeNode<K,V> p = new TreeNode<K,V>
(h, e.key, e.val, null, null);
if ((h & n) == 0) {
if ((p.prev = loTail) == null)
lo = p;
else
loTail.next = p;
loTail = p;
++lc;
}
else {
if ((p.prev = hiTail) == null)
hi = p;
else
hiTail.next = p;
hiTail = p;
++hc;
}
}
// 如果節(jié)點數(shù) 少于 6個艇拍,則紅黑樹還原成 鏈表,否則分別對兩個鏈表進(jìn)行紅黑樹處理
ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) :
(hc != 0) ? new TreeBin<K,V>(lo) : t;
hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) :
(lc != 0) ? new TreeBin<K,V>(hi) : t;
//把兩條已處理的結(jié)構(gòu) 整體遷移到nextTab中
setTabAt(nextTab, i, ln);
setTabAt(nextTab, i + n, hn);
//將原桶標(biāo)識位已經(jīng)處理
setTabAt(tab, i, fwd);
advance = true;
}
}
}
}
}
}
好了宠纯,協(xié)助擴(kuò)容操作就已經(jīng)看完了卸夕,我們總結(jié)一下,每個線程進(jìn)入的時候首先是領(lǐng)取自己的遷移區(qū)間婆瓜,然后通過 --i 來遍歷遷移區(qū)間中的每個桶的情況快集,如果是空桶贡羔,則插入ForwardingNode 標(biāo)志節(jié)點,如果是已經(jīng)ForwardingNode 節(jié)點開始个初,說明已經(jīng)完成了當(dāng)前桶的遷移乖寒,則跳過,如果是鏈表或者紅黑樹院溺,對桶加鎖宵统,正常的遷移即可,遷移結(jié)束后依然會將原來的表中添加ForwardingNode 標(biāo)志節(jié)點覆获。
接下來還有一個方法addCount的實現(xiàn)马澈,這里先解釋一下CounterCell數(shù)組的含義,它主要用于存儲節(jié)點數(shù)據(jù)已經(jīng)插入或更新到哈希表中弄息,但是baseCount沒有得到及時更新數(shù)據(jù)痊班,則會把這些數(shù)據(jù)存儲到CounterCell。
addCount
/**
* Adds to count, and if table is too small and not already
* resizing, initiates transfer. If already resizing, helps
* perform transfer if work is available. Rechecks occupancy
* after a transfer to see if another resize is already needed
* because resizings are lagging additions.
*
* @param x the count to add
* @param check if <0, don't check resize, if <= 1 only check if uncontended
*/
private final void addCount(long x, int check) {
CounterCell[] as; long b, s;
// 如果CounterCell數(shù)組中存在值摹量,則說明有 更新值沒有存儲到baseCount 中
// 并且CAS 中存儲的baseCount值 不一樣涤伐,需要把差量數(shù)據(jù)全量插入
// 如果相同則 更新 baseCount 的值 = baseCount + x
if ((as = counterCells) != null ||
!U.compareAndSwapLong(this, BASECOUNT, b = baseCount, s = b + x)) {
CounterCell a; long v; int m;
boolean uncontended = true;
//高并發(fā)下 CAS 失敗會執(zhí)行 fullAddCount 方法
if (as == null || (m = as.length - 1) < 0 ||
(a = as[ThreadLocalRandom.getProbe() & m]) == null ||
!(uncontended =
U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x))) {
fullAddCount(x, uncontended);
return;
}
if (check <= 1)
return;
s = sumCount();
}
if (check >= 0) {
Node<K,V>[] tab, nt; int n, sc;
// 檢查操作容量閾值,判斷是否需要擴(kuò)容處理
while (s >= (long)(sc = sizeCtl) && (tab = table) != null &&
(n = tab.length) < MAXIMUM_CAPACITY) {
int rs = resizeStamp(n);
if (sc < 0) {
if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
transferIndex <= 0)
break;
if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1))
transfer(tab, nt);
}
else if (U.compareAndSwapInt(this, SIZECTL, sc,
(rs << RESIZE_STAMP_SHIFT) + 2))
transfer(tab, null);
s = sumCount();
}
}
}
好了對于put 的分析就到這了缨称,對remove分析一下凝果,可以發(fā)現(xiàn)他跟put 的處理邏輯基本一樣。
其他一些常用的方法我們也看一下
/**
* {@inheritDoc}
*/
public int size() {
long n = sumCount();
return ((n < 0L) ? 0 :
(n > (long)Integer.MAX_VALUE) ? Integer.MAX_VALUE :
(int)n);
}
final long sumCount() {
CounterCell[] as = counterCells; CounterCell a;
long sum = baseCount;
if (as != null) {
for (int i = 0; i < as.length; ++i) {
if ((a = as[i]) != null)
sum += a.value;
}
}
return sum;
}
可以發(fā)現(xiàn)size 方法中不僅僅只有 baseCount 的值睦尽,還有我們剛剛提到的CounterCell的值器净。包含已經(jīng)計入baseCount的值,還包括高并發(fā)CAS 沒有更新到的數(shù)據(jù)值当凡,存儲在CounterCell中山害,兩個部分合起來才是最終的size大小。
get
/**
* Returns the value to which the specified key is mapped,
* or {@code null} if this map contains no mapping for the key.
*
* <p>More formally, if this map contains a mapping from a key
* {@code k} to a value {@code v} such that {@code key.equals(k)},
* then this method returns {@code v}; otherwise it returns
* {@code null}. (There can be at most one such mapping.)
*
* @throws NullPointerException if the specified key is null
*/
public V get(Object key) {
Node<K,V>[] tab; Node<K,V> e, p; int n, eh; K ek;
int h = spread(key.hashCode());
if ((tab = table) != null && (n = tab.length) > 0 &&
(e = tabAt(tab, (n - 1) & h)) != null) {
if ((eh = e.hash) == h) {
if ((ek = e.key) == key || (ek != null && key.equals(ek)))
return e.val;
}
else if (eh < 0)
return (p = e.find(h, key)) != null ? p.val : null;
while ((e = e.next) != null) {
if (e.hash == h &&
((ek = e.key) == key || (ek != null && key.equals(ek))))
return e.val;
}
}
return null;
}
get 就比較簡單了沿量,在對于讀操作是沒有添加鎖控制的浪慌。
clear
/**
* Removes all of the mappings from this map.
*/
public void clear() {
long delta = 0L; // negative number of deletions
int i = 0;
Node<K,V>[] tab = table;
while (tab != null && i < tab.length) {
int fh;
Node<K,V> f = tabAt(tab, i);
if (f == null)
++i;
else if ((fh = f.hash) == MOVED) {
// 協(xié)助擴(kuò)容之后需要重新開始計算
tab = helpTransfer(tab, f);
i = 0; // restart
}
else {
// 對每個桶處理 都會添加鎖處理
synchronized (f) {
if (tabAt(tab, i) == f) {
// 找到 鏈表或者紅黑樹的第一個節(jié)點,然后遍歷統(tǒng)計有多少個節(jié)點
Node<K,V> p = (fh >= 0 ? f :
(f instanceof TreeBin) ?
((TreeBin<K,V>)f).first : null);
while (p != null) {
--delta;
p = p.next;
}
// 清空桶的數(shù)據(jù)
setTabAt(tab, i++, null);
}
}
}
}
if (delta != 0L)
// 更新 哈希表的節(jié)點數(shù)
addCount(delta, -1);
}
好了朴则,就分析到這里了权纤,如果有什么分析不對的地方,請指正N诙省汹想!