public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
CGLIB_CLASS_SEPARATOR| Constructor and Description |
|---|
ThreadPoolExecutorFactoryBean() |
| Modifier and Type | Method and Description |
|---|---|
protected ThreadPoolExecutor |
createExecutor(int corePoolSize,
int maxPoolSize,
int keepAliveSeconds,
BlockingQueue<Runnable> queue,
ThreadFactory threadFactory,
RejectedExecutionHandler rejectedExecutionHandler)
Create a new instance of
ThreadPoolExecutor or a subclass thereof. |
protected BlockingQueue<Runnable> |
createQueue(int queueCapacity)
Create the BlockingQueue to use for the ThreadPoolExecutor.
|
ExecutorService |
getObject() |
Class<? extends ExecutorService> |
getObjectType() |
protected ExecutorService |
initializeExecutor(ThreadFactory threadFactory,
RejectedExecutionHandler rejectedExecutionHandler)
Create the target
ExecutorService instance. |
boolean |
isSingleton() |
void |
setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut)
Specify whether to allow core threads to time out.
|
void |
setCorePoolSize(int corePoolSize)
Set the ThreadPoolExecutor's core pool size.
|
void |
setExposeUnconfigurableExecutor(boolean exposeUnconfigurableExecutor)
Specify whether this FactoryBean should expose an unconfigurable
decorator for the created executor.
|
void |
setKeepAliveSeconds(int keepAliveSeconds)
Set the ThreadPoolExecutor's keep-alive seconds.
|
void |
setMaxPoolSize(int maxPoolSize)
Set the ThreadPoolExecutor's maximum pool size.
|
void |
setPrestartAllCoreThreads(boolean prestartAllCoreThreads)
Specify whether to start all core threads, causing them to idly wait for work.
|
void |
setQueueCapacity(int queueCapacity)
Set the capacity for the ThreadPoolExecutor's BlockingQueue.
|
afterPropertiesSet, cancelRemainingTask, destroy, initialize, setAwaitTerminationMillis, setAwaitTerminationSeconds, setBeanName, setRejectedExecutionHandler, setThreadFactory, setThreadNamePrefix, setWaitForTasksToCompleteOnShutdown, shutdownnewThreadcreateThread, getDefaultThreadNamePrefix, getShortName, getThreadGroup, getThreadNamePrefix, getThreadPriority, isDaemon, nextThreadName, setDaemon, setThreadGroup, setThreadGroupName, setThreadPrioritypublic void setCorePoolSize(int corePoolSize)
public void setMaxPoolSize(int maxPoolSize)
Integer.MAX_VALUE.public void setKeepAliveSeconds(int keepAliveSeconds)
public void setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut)
Default is "false".
public void setPrestartAllCoreThreads(boolean prestartAllCoreThreads)
Default is "false".
ThreadPoolExecutor.prestartAllCoreThreads()public void setQueueCapacity(int queueCapacity)
Integer.MAX_VALUE.
Any positive value will lead to a LinkedBlockingQueue instance; any other value will lead to a SynchronousQueue instance.
LinkedBlockingQueue,
SynchronousQueuepublic void setExposeUnconfigurableExecutor(boolean exposeUnconfigurableExecutor)
Default is "false", exposing the raw executor as bean reference. Switch this flag to "true" to strictly prevent clients from modifying the executor's configuration.
protected ExecutorService initializeExecutor(ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler)
ExecutorConfigurationSupportExecutorService instance.
Called by afterPropertiesSet.initializeExecutor in class ExecutorConfigurationSupportthreadFactory - the ThreadFactory to userejectedExecutionHandler - the RejectedExecutionHandler to useExecutorConfigurationSupport.afterPropertiesSet()protected ThreadPoolExecutor createExecutor(int corePoolSize, int maxPoolSize, int keepAliveSeconds, BlockingQueue<Runnable> queue, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler)
ThreadPoolExecutor or a subclass thereof.
The default implementation creates a standard ThreadPoolExecutor.
Can be overridden to provide custom ThreadPoolExecutor subclasses.
corePoolSize - the specified core pool sizemaxPoolSize - the specified maximum pool sizekeepAliveSeconds - the specified keep-alive time in secondsqueue - the BlockingQueue to usethreadFactory - the ThreadFactory to userejectedExecutionHandler - the RejectedExecutionHandler to useExecutorConfigurationSupport.afterPropertiesSet()protected BlockingQueue<Runnable> createQueue(int queueCapacity)
A LinkedBlockingQueue instance will be created for a positive capacity value; a SynchronousQueue else.
queueCapacity - the specified queue capacityLinkedBlockingQueue,
SynchronousQueuepublic ExecutorService getObject()
public Class<? extends ExecutorService> getObjectType()
public boolean isSingleton()
Copyright © 2025. All rights reserved.