私は次のJavaコードを持っています:
HashMap<Integer, Lesson> overflow = new HashMap<Integer, Lesson>();
HashMap<Integer, Lesson> new_lessons = this.lessons;
HashMap<Integer, Lesson> lessons = this.lessons;
for (Integer lesson : lessons.keySet()) {
if(lessons.get(lesson).getLength().equals(LessonLength.DOUBLE)){
if(lessons.containsKey(lesson + 1)){
overflow.put(lesson + 1, lessons.get(lesson + 1));
new_lessons.put(lesson+1, lessons.get(lesson));
new_lessons.get(lesson).setLength(LessonLength.ONCE);
new_lessons.get(lesson+1).setLength(LessonLength.ONCE);
}
else{
new_lessons.put(lesson+1, lessons.get(lesson));
new_lessons.get(lesson).setLength(LessonLength.ONCE);
new_lessons.get(lesson+1).setLength(LessonLength.ONCE);
}
}
}
ConcurrentModificationException がスローされるのはなぜですか?