public class Test implements Runnable {
int flag = 0;
long i = 0;
long tempStart = 0;
long tempEnd = 0;
public Test() {
new Thread(this).start();
while (true) {
i++;
}
}
@Override
public void run() {
while (true) {
try {
tempStart = i;
Thread.sleep(1000);
tempEnd = i;
System.out.println("每秒迴圈執行:" + (tempEnd - tempStart) + " 次");
flag++;
} catch (Exception e) {
}
}
}
public static void main(String[] args) {
new Test();
}
全站熱搜