-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
None
-
x86
-
windows_nt
//In the following program with i.remove()
//ConcurrentModificationException not thrown.
import java.util.*;
public class Test {
public static void main(String[] args) throws Exception {
List orgLinkedList = new LinkedList();
for (int i=0; i<100; i++) {
orgLinkedList.add(new Integer(i));
}
List copyLinkedList = new LinkedList(orgLinkedList);
try {
ListIterator i = copyLinkedList.listIterator();
i.next();
copyLinkedList.add(1,new Integer(8888));
i.remove();
//i.add(new Integer(2222));
throw new Exception("remove in iterator didn't fail fast");
} catch(ConcurrentModificationException e) {
System.out.println("ConcurrentModificationException = " + e);
}
}
}
//ConcurrentModificationException not thrown.
import java.util.*;
public class Test {
public static void main(String[] args) throws Exception {
List orgLinkedList = new LinkedList();
for (int i=0; i<100; i++) {
orgLinkedList.add(new Integer(i));
}
List copyLinkedList = new LinkedList(orgLinkedList);
try {
ListIterator i = copyLinkedList.listIterator();
i.next();
copyLinkedList.add(1,new Integer(8888));
i.remove();
//i.add(new Integer(2222));
throw new Exception("remove in iterator didn't fail fast");
} catch(ConcurrentModificationException e) {
System.out.println("ConcurrentModificationException = " + e);
}
}
}
- duplicates
-
JDK-4308549 LinkedList listIterator Remove why NO checkForComodication?
-
- Closed
-