Cancel without interruption of currently running tasks

Leave potential interruption up to scheduler shutdown.

Closes gh-31019
This commit is contained in:
Juergen Hoeller 2023-08-09 23:53:35 +02:00
parent d58e48d9f5
commit 6fc5a78252
2 changed files with 3 additions and 3 deletions

View File

@ -577,7 +577,7 @@ public class ScheduledAnnotationBeanPostProcessor
} }
if (tasks != null) { if (tasks != null) {
for (ScheduledTask task : tasks) { for (ScheduledTask task : tasks) {
task.cancel(); task.cancel(false);
} }
} }
} }
@ -595,7 +595,7 @@ public class ScheduledAnnotationBeanPostProcessor
Collection<Set<ScheduledTask>> allTasks = this.scheduledTasks.values(); Collection<Set<ScheduledTask>> allTasks = this.scheduledTasks.values();
for (Set<ScheduledTask> tasks : allTasks) { for (Set<ScheduledTask> tasks : allTasks) {
for (ScheduledTask task : tasks) { for (ScheduledTask task : tasks) {
task.cancel(); task.cancel(false);
} }
} }
this.scheduledTasks.clear(); this.scheduledTasks.clear();

View File

@ -553,7 +553,7 @@ public class ScheduledTaskRegistrar implements ScheduledTaskHolder, Initializing
@Override @Override
public void destroy() { public void destroy() {
for (ScheduledTask task : this.scheduledTasks) { for (ScheduledTask task : this.scheduledTasks) {
task.cancel(); task.cancel(false);
} }
if (this.localExecutor != null) { if (this.localExecutor != null) {
this.localExecutor.shutdownNow(); this.localExecutor.shutdownNow();