यहाँ मेरी कोड है:"java.util.ConcurrentModificationException" के साथ अटक
// 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();
) में फेंक दिया है। क्या आप मेरे कोड में एक गलती देखते हैं जो उस अपवाद को फेंकने का कारण स्पष्ट करता है?
संभावित डुप्लिकेट [निकालने के साथ सूची पर लूप] (http://stackoverflow.com/questions/1921104/loop-on-list-with-remove) – McDowell