JAVA/복습
시간 구하기 예제
Frog is cry
2020. 7. 30. 17:46
package 스레드.ex04_TimeCheck;
public class TimeCheck {
public static void main(String[] args) {
// 시간 구하기
long start = System.currentTimeMillis(); // 현재 시간을 밀리초로 나타냄
long end = 0L;
int ar [] = new int[10000000];
for (int i = 0; i < ar.length; i++) {
ar[i] = i;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
end = System.currentTimeMillis();
System.out.println((end-start)/1000.0 + "초");
}
}