scheduleAtFixedRate vs scheduleWithFixedDelay

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

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

scheduler.s         


        
7条回答
  •  青春惊慌失措
    2020-12-04 06:30

    Visualize time series of invocation scheduleAtFixedRate method. Next executions will start immediately if the last one takes longer than period. Otherwise, it will start after period time.

    time series of invocation scheduleAtFixedRate method

    Time series of invocation scheduleWithFixedDelay method. Next execution will start after delay time between termination of one execution and the commencement of the next, regardless of its execution time

    time series of invocation scheduleWithFixedDelay method

    Hope can help you

提交回复
热议问题