p = f; p != lastRun; p = p.next) {int ph = p.hash; K pk = p.key; V pv = p.val;if ((phelsehn = new Node(ph, pk, pv, hn);}//将新node链表赋给nextTabsetTabAt(nextTab, i, ln);setTabAt(nextTab, i + n, hn);setTabAt(tab, i, fwd);advance = true;}//红黑树迁移else if (f instanceof TreeBin) {TreeBin t = (TreeBin)f;TreeNode lo = null, loTail = null;TreeNode hi = null, hiTail = null;int lc = 0, hc = 0;for (Node e = t.first; e != null; e = e.next) {int h = e.hash;TreeNode p = new TreeNode(h, e.key, e.val, null, null);if ((helseloTail.next = p;loTail = p;++lc;}else {if ((p.prev = hiTail) == null)hi = p;elsehiTail.next = p;hiTail = p;++hc;}}ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) :(hc != 0) ? new TreeBin(lo) : t;hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) :(lc != 0) ? new TreeBin(hi) : t;setTabAt(nextTab, i, ln);setTabAt(nextTab, i + n, hn);setTabAt(tab, i, fwd);advance = true;}}}}}}作者:故人
出处:
【并发容器ConcurrentHashMap】突击并发编程JUC系列演示代码地址: