Why i getting the ConcurrentModificationException
. With this programming style it should not appear. Have i missing something? I can't find any solution to that problem. This code is called every second with @Scheduled in Spring.
Iterator<Entry<String, Integer>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, Integer> entry= iterator.next(); // this row throw the expection
while (entry.getValue().compareTo(value) <= 0) {
iterator.remove();
}
}
question from:
https://stackoverflow.com/questions/65835612/concurrentmodificationexception-map 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…