我是一名初学java程序员,我在网上看到关于我的projet的代码。 但我不明白它的作用?任何人都能解释? 什么是1000s?为初学者解释java代码
private Timer timer = null;
private int timeWorking;
private void xxxxxxxxxxx() {
if (timer == null) {
timer = new Timer("Time");
timer.schedule(new TimerTask() {
@Override
public void run() {
timeWorking++;
}
}, 1000, 1000);
}
}
毫秒或一秒钟。它每秒调度一次回调(到'TimerTask'),并有第二次延迟。查看[Timer的JavaDocs](https://docs.oracle.com/javase/7/docs/api/java/util/Timer.html)以获取更多详细信息 – MadProgrammer
检查Timer类的api 。 – Stultuske
...位于https://docs.oracle.com/javase/8/docs/api/java/util/Timer.html#schedule-java.util.TimerTask-long-long- – gustafc