ConcurrentModificationException引起的问题
ConcurrentModificationException引起的问题
现象
这是一个由ConcurrentModificationException引发的问题,先看下这段程序:
List<String> tmpList1 = new LinkedList<>();
tmpList1.add("Hello");
tmpList1.add("My");
tmpList1.add("Son");
for (String curStr : tmpList1) {
if ("My".equals(curStr)) {
tmpList1.remove(curStr);
}
System.out.printf("curStr = %s, tmpList = %s\n", curStr, tmpList1.toString());
}