반응형
thread sleep을 이용하여 1~3초 랜덤으로 반복문 for문을 실행하여 일련의 작업을 수행
for(int i=0; i<10; i++){
// 랜덤으로 sleep 랜덤 시간 설정
// 1000 : 1초
// 3000 : 3초
int randomCnt = (int) (Math.random() * 3 + 1) * 1000;
try {
Thread.sleep (randomCnt);
System.out.println("sleep ::::::"+ i +" 번째 " + randomCnt);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

반응형
'웹프로그래밍 > Java' 카테고리의 다른 글
이클립스 톰켓 재시작 안될때, 포트 사용중, 포트 죽이기 (0) | 2021.10.20 |
---|---|
[JAVA, SPRING] SPRING JSON DATA RESPONSE 한글 깨짐 (0) | 2021.06.04 |
리눅스(linux), 윈도우(windows) 개발/운영 WAS, WEB IP 구하기 (0) | 2021.04.27 |
[java] 실제경로에 파일 사이즈 구하기 (1) | 2020.11.27 |
java.lang.RuntimePermission 에러 (0) | 2019.07.19 |