Skip to content

Instantly share code, notes, and snippets.

@why-jay
Created January 24, 2015 06:10
Show Gist options
  • Save why-jay/d22bc6ff61059cd4c188 to your computer and use it in GitHub Desktop.
Save why-jay/d22bc6ff61059cd4c188 to your computer and use it in GitHub Desktop.
List<Runnable> actions = new ArrayList<Runnable>();
for (int counter = 0; counter < 10; counter++) {
final int copy = counter; // notice the `final` keyword!
actions.add(new Runnable() {
public void run() { System.out.println(copy); }
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment