Java 计划执行器 : Does it guarantee to not run in parallel if task hast not yet finished

标签 java executor

有谁知道 java.util.concurrent 包中的以下 java 方法 ScheduledExecutorService.html#scheduleAtFixedRate()

绝对保证,如果“最后一次”运行的可运行对象尚未完成,则 Runnable 计划永远不会并行运行:

例如(伪代码)

1.00 o'clock: scheduleAtFixedRate(MyRunnable, "Run ever Hour")`
//1.30 o'clock: MyRunnable Has finished (everthing is fine)
2.00 o'clock: MyRunnable is triggered to run again
3.00 o'clock: MyRunnable has NOT yet finished ==> What will happen here? 
Will java Simply SKIP the starting of MyRunnable (as the old instance has not yet 
finished) and try again at 4 o'clock or will Java start a NEW MyRunnable that then will 
run in parallel to the "old" MyRunnable.

非常感谢 简

最佳答案

来自docs :

If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

关于Java 计划执行器 : Does it guarantee to not run in parallel if task hast not yet finished,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1632371/

相关文章:

无法对任务进行排队的 Java 执行器

java - ThreadPool 不按顺序运行任务

java - 适用于非线程安全代码的执行器

java - Weka K-means 中的理想簇数

应该永远运行的任务的 Java Executor 最佳实践

java - 使用多个套件进行测试。 @AfterSuite 方法在第一个套件和第二个套件无法运行后关闭驱动程序

java - MEKA >> 错误 : Could not find or load main class .\lib\Jama.jar

job-scheduling - Spark Streaming 中的作业是如何分配给执行者的?

java - Tomcat 版本未启动

java - Java中如何传递泛型参数