关于java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate:它执行任务的频率如何?

时间:2019-05-26 18:18:06

标签: java executorservice scheduledexecutorservice

我正在查看-> java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate

的javadoc

我在javadoc下面重新制作了

ScheduledFuture<?> java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)

创建并执行一个周期性操作,该操作将在给定的初始延迟后首先启用,然后在给定的周期后启用;也就是说,执行将在initialDelay,initialDelay + period,initialDelay + 2 *期间等之后开始。如果任务的任何执行遇到异常,则后续执行将被禁止。否则,任务将仅通过取消或终止执行程序而终止。如果此任务的执行时间超过其执行时间,则随后的执行可能会延迟执行,但不会同时执行。

Parameters:
command the task to execute

initialDelay the time to delay first execution

period the period between successive executions

unit the time unit of the initialDelay and period parameters
Returns:
a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation

我知道第一次在initialDelay之后启用,然后在period之后重复启用。但是,查看上面的突出显示的部分,似乎连续执行之间的频率正在增加。

这是正确的行为吗?如果是这样,那么延迟会比以前的执行增加吗?

任何人都可以帮助澄清吗?

0 个答案:

没有答案