Skip to content

Instantly share code, notes, and snippets.

@sergiilagutin
Created March 12, 2015 18:40
Show Gist options
  • Save sergiilagutin/7d798f24c752a36b5807 to your computer and use it in GitHub Desktop.
Save sergiilagutin/7d798f24c752a36b5807 to your computer and use it in GitHub Desktop.
Force ConcurrentModificationException in single-thread application
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