Created
March 12, 2015 18:40
-
-
Save sergiilagutin/7d798f24c752a36b5807 to your computer and use it in GitHub Desktop.
Force ConcurrentModificationException in single-thread application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
List<String> list = new ArrayList<>(); | |
list.add("one"); | |
list.add("two"); | |
for( String str : list) { | |
System.out.println(str); | |
list.add("three") | |
} | |
// program print "one" and then throws ConcurrentModificationException in next iteration. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment