Browse Source

Align task execution tracking and thread interruption on shutdown

Closes gh-35254
pull/35405/head
Juergen Hoeller 5 months ago
parent
commit
67e88f3c20
  1. 2
      spring-context/src/main/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskScheduler.java
  2. 2
      spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

2
spring-context/src/main/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskScheduler.java

@ -376,7 +376,7 @@ public class SimpleAsyncTaskScheduler extends SimpleAsyncTaskExecutor implements
@Override @Override
public boolean isRunning() { public boolean isRunning() {
return this.triggerLifecycle.isRunning(); return (this.triggerLifecycle.isRunning() || this.fixedDelayLifecycle.isRunning());
} }
@Override @Override

2
spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

@ -364,7 +364,6 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator
this.active = false; this.active = false;
Set<Thread> threads = this.activeThreads; Set<Thread> threads = this.activeThreads;
if (threads != null) { if (threads != null) {
threads.forEach(Thread::interrupt);
synchronized (threads) { synchronized (threads) {
try { try {
if (!threads.isEmpty()) { if (!threads.isEmpty()) {
@ -375,6 +374,7 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
threads.forEach(Thread::interrupt);
} }
} }
} }

Loading…
Cancel
Save