-
Tech Note 정보
-
¯\_(ツ)_/¯ 님이 작성하신 글입니다.
-
카테고리: [ Development ]
-
-
-
-
조회수: 1892
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class Main {
public static void main(String[] args) {
int sleepSec = 10;
final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
final ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
exec.scheduleAtFixedRate(new Runnable() {
public void run() {
try {
Calendar cal = Calendar.getInstance();
System.out.println(sdf.format(cal.getTime()));
} catch (Exception e) {
e.printStackTrace();
exec.shutdown();
}
}
}, 0, sleepSec, TimeUnit.SECONDS);
}
}