java - scheduleWithFixedDelay() 和 scheduleFixedRate() 区别
迷茫
迷茫 2017-04-18 09:34:05
0
1
906

ScheduledExecutorService类 scheduleWithFixedDelay() 和 scheduleFixedRate() 区别

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
左手右手慢动作

I guess what you want to say is the scheduleAtFixedRate method

  1. scheduleAtFixedRate(Runnable command,long initialDelay,long period,TimeUnit unit)
    We can use this method to delay the execution of tasks and set the execution cycle of the task. The time period is calculated from the thread that first starts executing in the thread pool, so assuming that the period is 1s and the thread executes for 5s, the next thread will be executed soon after the first thread finishes running.

  2. scheduleWithFixedDelay(Runnable command,long initialDelay,long delay,TimeUnit unit)
    This method can be used to delay periodic execution of tasks. delaytime is the delay time between the thread stopping execution and the next start of execution. Assume the following code

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template