这是我的代码:
// eventList is a LinkedList
public void run() {
Iterator<Event> it = eventList.iterator();
int size = eventList.size();
while(size > 0) {
while(it.hasNext()) {
Event e = it.next(); //flaged line
if(e.ready()) {
System.out.println(e);
e.action();
eventList.remove(e);
--size;
}
}
}
}
错误java.util.ConcurrentModificationException
会在标记线 ( Event e = it.next();
) 处引发。您是否在我的代码中看到一个错误,该错误使引发该异常的原因显而易见?