为什么retrieveObjects.addAll会导致java.util.ConcurrentModificationException?它不会每次都发生,但偶尔抛出ConcurrentModificationException,我无法弄清楚原因。
public Set<Obj> retrieve(Vector2 pos, float radius) {
Set<Obj> retrievedObjects = new HashSet<>();
String[] grids = getGridsObjIsIn(pos, radius);
for (String grid : grids) {
if (objects.containsKey(grid)) {
retrievedObjects.addAll(objects.get(grid));
}
}
return retrievedObjects;
}