Skip to content

Instantly share code, notes, and snippets.

@lostdj
Created October 16, 2012 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lostdj/3897345 to your computer and use it in GitHub Desktop.
Save lostdj/3897345 to your computer and use it in GitHub Desktop.
public class Loop {
public static volatile int k = 10000;
public static volatile int s = 0;
public static volatile int i = 0;
public static volatile int j = 0;
public static void foo()
{
for (s=0,i=0;i<k;i++) {
for (j=0;j<k;j++)
s+=i*j;
}
System.out.println(s);
}
public static void main(String[] args) throws Exception {
// Warm-up.
foo();
foo();
foo();
foo();
foo();
foo();
foo();
System.out.println(System.currentTimeMillis());
foo();
System.out.println(System.currentTimeMillis());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment