代码
调用 内联代码片
。
// 调用
scheduledExecutorService.scheduleWithFixedDelay(
this::execute, 0, restConfig.getIntervalTime(), TimeUnit.MILLISECONDS );
方法内联代码片
。
// 调用
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit);
解释
参数:
command - 要执行的任务
initialdelay - 首次执行的延迟时间
delay - 一次执行终止和下一次执行开始之间的延迟
unit - initialdelay 和 delay 参数的时间单位
返回:
表示挂起任务完成的 scheduledfuture,并且其 get() 方法在取消后将抛出异常
抛出:
rejectedexecutionexception - 如果无法安排执行该任务
nullpointerexception - 如果 command 为 null。
illegalargumentexception - 如果 delay 小于等于 0