2

有谁知道 java.util.concurrent 包中是否有以下 java 方法ScheduledExecutorService.html#scheduleAtFixedRate()

绝对保证,如果“最后”运行的可运行对象尚未完成,则 Runnable 计划将永远不会并行运行:

例如(伪代码)

1.00 o'clock: scheduleAtFixedRate(MyRunnable, "Run ever Hour")`
//1.30 o'clock: MyRunnable Has finished (everthing is fine)
2.00 o'clock: MyRunnable is triggered to run again
3.00 o'clock: MyRunnable has NOT yet finished ==> What will happen here? 
Will java Simply SKIP the starting of MyRunnable (as the old instance has not yet 
finished) and try again at 4 o'clock or will Java start a NEW MyRunnable that then will 
run in parallel to the "old" MyRunnable.

非常感谢简

4

1 回答 1

2

文档

如果此任务的任何执行时间超过其周期,则后续执行可能会延迟开始,但不会同时执行。

于 2009-10-27T17:31:26.360 回答