Expose prestartAllCoreThreads on ExecutorService
See gh-1246
This commit is contained in:
committed by
Stephane Nicoll
parent
2271b6078e
commit
2c53e9e308
@@ -73,12 +73,14 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
|
||||
|
||||
private int keepAliveSeconds = 60;
|
||||
|
||||
private boolean allowCoreThreadTimeOut = false;
|
||||
|
||||
private int queueCapacity = Integer.MAX_VALUE;
|
||||
|
||||
private boolean allowCoreThreadTimeOut = false;
|
||||
|
||||
private boolean exposeUnconfigurableExecutor = false;
|
||||
|
||||
private boolean prestartAllCoreThreads = false;
|
||||
|
||||
@Nullable
|
||||
private ExecutorService exposedExecutor;
|
||||
|
||||
@@ -130,6 +132,17 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
|
||||
this.queueCapacity = queueCapacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether this FactoryBean should prestart all threads
|
||||
* for the created executor.
|
||||
* <p>Default is "false".
|
||||
* Switch this flag to "true" to prestart the threads allocated for the current executor
|
||||
* @see java.util.concurrent.ThreadPoolExecutor#prestartAllCoreThreads
|
||||
*/
|
||||
public void setPrestartAllCoreThreads(boolean prestartAllCoreThreads) {
|
||||
this.prestartAllCoreThreads = prestartAllCoreThreads;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether this FactoryBean should expose an unconfigurable
|
||||
* decorator for the created executor.
|
||||
@@ -154,6 +167,10 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
|
||||
executor.allowCoreThreadTimeOut(true);
|
||||
}
|
||||
|
||||
if (this.prestartAllCoreThreads) {
|
||||
executor.prestartAllCoreThreads();
|
||||
}
|
||||
|
||||
// Wrap executor with an unconfigurable decorator.
|
||||
this.exposedExecutor = (this.exposeUnconfigurableExecutor ?
|
||||
Executors.unconfigurableExecutorService(executor) : executor);
|
||||
|
||||
Reference in New Issue
Block a user