Last active
December 11, 2015 21:49
-
-
Save simonharrer/4665424 to your computer and use it in GitHub Desktop.
Code Puzzler - Different Behaviour in Java and Groovy
This file contains hidden or 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
package betsy; | |
public class CodePuzzler { | |
public static void main(String[] args) { | |
// init array | |
String[] array = new String[2]; | |
array[0] = "One"; | |
array[1] = "Two"; | |
// iterate and print in thread | |
for(final String element : array){ | |
new Thread() { | |
public void run() { | |
System.out.println(element); | |
} | |
}.start(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment