Created
January 25, 2016 09:49
-
-
Save nitsanw/a8b20fc6ecbb9ae9c054 to your computer and use it in GitHub Desktop.
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
public class WhenWillItExitInt3 { | |
public static void main(String[] argc) throws InterruptedException { | |
for (int i=0;i<100000;i++) { | |
countOdds(10); | |
} | |
Thread t = new Thread(() -> { | |
long l = countOdds(Integer.MAX_VALUE); | |
System.out.println("How Odd:" + l); | |
}); | |
t.setDaemon(true); | |
t.start(); | |
Thread.sleep(5000); | |
} | |
private static long countOdds(int limit) { | |
long l = 0; | |
for (int i = 0; i < limit; i++) { | |
for (int j = 0; j < limit; j++) { | |
if ((j & 1) == 1) | |
l++; | |
} | |
} | |
return l; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment