diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java index 7979e07d73a..ef062e9fef8 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java @@ -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(); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorLifecycleDelegate.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorLifecycleDelegate.java index e4516eea460..c78efa1455f 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorLifecycleDelegate.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorLifecycleDelegate.java @@ -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) {