我正在尝试遍历 Integer ArrayList 并获取每个元素的值,但我在 int value = ... 处遇到错误。
不知道发生了什么。请指教。
Iterator<Integer> listItr = executeList.iterator(); // iterator for the execute list
while (listItr.hasNext()) { // iterate through list and do work!
int robIndex = listItr.next();
int timer = fakeRob.exeCountDown(robIndex); // decrement first then return timer
if (timer == 0) {// check if instr finished execution
System.out.println("timer expired. fire");
executeList.remove(executeList.indexOf(robIndex)); // 1. remove instr from exeList
transitState(robIndex, EX, WB); // 2. transit from EX state to WB state
int tag = fakeRob.getTag(robIndex); // get producer tag
regFile.setRdy(tag); // 3a. set register file ready flag for this tag
fakeRob.wakeUp(tag); // 3b. wake up instructions with this tag
}
}
错误:
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at sim.execute(sim.java:180)
at sim.<init>(sim.java:71)
at sim.main(sim.java:270
谢谢,
汉克