Reliably unpause execution thread in case of late shutdown

Closes gh-37406
This commit is contained in:
Juergen Hoeller
2026-10-06 19:14:07 +02:00
parent f0f71009b2
commit f660a68319
2 changed files with 11 additions and 1 deletions
@@ -366,6 +366,9 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac
logger.debug("Shutting down ExecutorService" + (this.beanName != null ? " '" + this.beanName + "'" : ""));
}
if (this.executor != null) {
if (this.lifecycleDelegate != null && this.lateShutdown) {
this.lifecycleDelegate.markShutdown();
}
if (this.waitForTasksToCompleteOnShutdown) {
this.executor.shutdown();
}
@@ -104,7 +104,14 @@ final class ExecutorLifecycleDelegate implements SmartLifecycle {
}
void markShutdown() {
this.shutdown = true;
this.pauseLock.lock();
try {
this.shutdown = true;
this.unpaused.signalAll();
}
finally {
this.pauseLock.unlock();
}
}
void beforeExecute(Thread thread) {