728x90 반응형 SMALL concurrentmodification exception1 ConcurrentModificationException 데이터를 순회하면서 특정 data를 조작(삭제)하고 싶을 때 발생한다. Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Entry entry = it.next(); if (entry != null && entry.getValue().compareTo(actualExpiredTime) < 0) { map.remove(entry.getKey()); } } Java 공식 문서를 보면 Iterator 의 remove를 이용하는 것이 Collection을 순회하면서 element를 삭제하는 유일하게 안전한 방법이라고 가이드 하고 있다. 그래서 소스코드를 바꿔본다. Iterator it = map.entrySet().iterator(); while .. 2019. 5. 21. 이전 1 다음 728x90 반응형 LIST