Skip to content

Commit a13768d

Browse files
authored
Merge pull request Snailclimb#373 from tianyu94/master
fix : typo
2 parents c19d4f9 + 24afdff commit a13768d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/java/collection/Java集合框架常见面试题.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static class Segment<K,V> extends ReentrantLock implements Serializable {
284284

285285
### JDK1.8 (上面有示意图)
286286

287-
ConcurrentHashMap取消了Segment分段锁,采用CAS和synchronized来保证并发安全。数据结构跟HashMap1.8的结构类似,数组+链表/红黑二叉树。Java 8在链表长度超过一定阈值(8)时将链表(寻址时间复杂度为O(N))转换为红黑树(寻址时间复杂度为O(long(N)))
287+
ConcurrentHashMap取消了Segment分段锁,采用CAS和synchronized来保证并发安全。数据结构跟HashMap1.8的结构类似,数组+链表/红黑二叉树。Java 8在链表长度超过一定阈值(8)时将链表(寻址时间复杂度为O(N))转换为红黑树(寻址时间复杂度为O(log(N)))
288288

289289
synchronized只锁定当前链表或红黑二叉树的首节点,这样只要hash不冲突,就不会产生并发,效率又提升N倍。
290290

0 commit comments

Comments
 (0)