What should Timertask.scheduleAtFixedRate do if the clock changes?

后端 未结 2 755
滥情空心
滥情空心 2020-12-03 16:17

We want to run a task every 1000 seconds (say).

So we have

timer.scheduleAtFixedRate(task, delay, interval);

Mostly, this works fin

2条回答
  •  眼角桃花
    2020-12-03 16:51

    It is reported here http://bugs.sun.com/view_bug.do?bug_id=4290274

    Similarly, when the system clock is set to a later time, the task may be run multiple times without any delay to "catch up" the missed executions. Exactly this happens when the computer is set to standby/hibernate and the application is resumed (this is how I found out).

    This behavior can also be seen in a Java debugger by suspending the timer thread and resuming it.

提交回复
热议问题