最开始我使用了这种测试方式,测试了1百万次for循环
public class Main {
public static void main(String[] args) {
long start = System.currentTimeMillis();
for (int j = 0; j < 1000000; j++){
}
long stop = System.currentTimeMillis();
System.out.println(stop - start);
}
}
image.png
测试结果,what???4ms这处理器这么快吗,自己的老爷机心里还是有点B数的,一定的那个智能的编译器或者时jvm给我做了优化,于是
public class Main {
public static void main(String[] args) throws InterruptedException {