我是一名初學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