Skip to content

Instantly share code, notes, and snippets.

@maartenl
Created November 20, 2012 08:00
Show Gist options
  • Save maartenl/4116664 to your computer and use it in GitHub Desktop.
Save maartenl/4116664 to your computer and use it in GitHub Desktop.
An example of an iteration over a synchronized list, found in the javadoc.
List list = Collections.synchronizedList(new ArrayList());
synchronized (list) {
Iterator i = list.iterator(); // Must be in synchronized block
while (i.hasNext())
foo(i.next());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment