package com.qs.thread;
import java.time.LocalDateTime;
import java.util.Timer;
import java.util.TimerTask;
public class TraditionalTimerTest5 {
public static void main(String[] args) {
new Timer().schedule(new MyTimerTask(), 2000);
while (true) {
System.out.println(LocalDateTime.now().getSecond());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static class MyTimerTask extends TimerTask {
public void run() {
System.out.println("bombing!");
new Timer().schedule(new MyTimerTask(), 2000);
}
}
}
Java获取当前秒数
最新推荐文章于 2024-08-12 03:29:22 发布