Skip to content

Commit 988811b

Browse files
committed
Update Java Notes
1 parent 797a03d commit 988811b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Java.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23661,7 +23661,10 @@ public static void main(String[] args) throws InterruptedException {
2366123661

2366223662
* 快速失败:在 A 线程使用迭代器对集合进行遍历的过程中,此时 B 线程对集合进行修改(增删改),或者 A 线程在遍历过程中对集合进行修改,都会导致 A 线程抛出 ConcurrentModificationException 异常
2366323663
* AbstractList 类中的成员变量 modCount,用来记录 List 结构发生变化的次数,**结构发生变化**是指添加或者删除至少一个元素的操作,或者是调整内部数组的大小,仅仅设置元素的值不算结构发生变化
23664+
2366423665
* 在进行序列化或者迭代等操作时,需要比较操作前后 modCount 是否改变,如果改变了抛出 CME 异常
23666+
23667+
2366523668
* 安全失败:采用安全失败机制的集合容器,在遍历时不是直接在集合内容上访问的,而是先复制原有集合内容,在拷贝的集合上进行遍历。由于迭代时是对原集合的拷贝进行遍历,所以在遍历过程中对原集合所作的修改并不能被迭代器检测到,故不会抛 ConcurrentModificationException 异常
2366623669

2366723670

0 commit comments

Comments
 (0)