scheduleAtFixedRate vs scheduleWithFixedDelay

后端 未结 7 1471
时光说笑
时光说笑 2020-12-04 06:18

What\'s the main difference between scheduleAtFixedRate and scheduleWithFixedDelay methods of ScheduledExecutorService?

scheduler.s         


        
相关标签:
7条回答
  • 2020-12-04 06:45

    If you read the Java Doc it will be clearer

    ScheduledFuture scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is executions will commence after initialDelay then initialDelay+period, then initialDelay + 2 * period, and so on.

    ScheduledFuture scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.

    0 讨论(0)
提交回复
热议问题