1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

添加jdk1.8解决HashMap扩容死循环问题

添加jdk1.8解决HashMap扩容死循环问题
This commit is contained in:
木木匠 2018-10-16 16:15:23 +08:00 committed by GitHub
parent fa64796572
commit 7390ef6ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,6 +190,7 @@ static int hash(int h) {
这个过程为,先将 A 复制到新的 hash 表中,然后接着复制 B 到链头A 的前边B.next=A本来 B.next=null到此也就结束了跟线程二一样的过程但是由于线程二扩容的原因将 B.next=A所以这里继续复制A让 A.next=B由此环形链表出现B.next=A; A.next=B
**注意jdk1.8已经解决了死循环的问题。**
## HashSet 和 HashMap 区别