Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e4f41df

Browse files
committed
增加时间复杂度的描述
1 parent 166fdbf commit e4f41df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎docs/java/这几道Java集合框架面试题几乎必问.md‎

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

251251
### JDK1.8 (上面有示意图)
252252

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

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /