public class ThreadPoolExecutorFactoryBean
extends java.lang.Object
implements org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
ThreadPoolExecutor instances,
which cannot easily be constructed using constructor injection. This instance
also allows the setting of the thread-specific properties that would otherwise
require setting a ThreadFactory.
This factory provides the a singleton instance of the pool.
Defaults are:
corePoolSize:
20maximumPoolSize:
Equal to the ThreadPoolExecutorFactoryBean.setCorePoolSize(int) at the time of instance creationkeepAliveTime:
90 secondsthreadPriority:
5 (NORM)threadDaemon:
trueworkQueueSize:
-1 or less (No upper bound)ThreadPoolExecutor.CallerRunsPolicy| Constructor and Description |
|---|
ThreadPoolExecutorFactoryBean()
Constructor setting default properties:
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
destroy() |
java.lang.Object |
getObject() |
java.lang.Class |
getObjectType() |
java.lang.String |
getPoolName() |
boolean |
isSingleton() |
void |
setCorePoolSize(int corePoolSize)
The number of threads to keep in the pool, even if idle.
|
void |
setKeepAliveTime(int keepAliveTime)
The time (in seconds) to keep non-core idle threads in the pool
|
void |
setMaximumPoolSize(int maximumPoolSize)
The maximum number of threads to keep in the pool
|
void |
setPoolName(java.lang.String poolName) |
void |
setRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
The optional handler for when tasks cannot be submitted to the queue.
|
void |
setThreadDaemon(boolean threadDaemon)
Set whether the threads run as daemon threads or not.
|
void |
setThreadPriority(int threadPriority)
The priority that all threads must have on the scale of 1 to 10,
where 1 has the lowest priority and 10 has the highest priority.
|
void |
setWorkQueueSize(int workQueueSize)
The maximum number of queued work instances to keep before blocking
against further adds.
|
public ThreadPoolExecutorFactoryBean()
public void setCorePoolSize(int corePoolSize)
corePoolSize - core thread countpublic void setMaximumPoolSize(int maximumPoolSize)
maximumPoolSize - the maximum number of threads in the poolpublic void setKeepAliveTime(int keepAliveTime)
keepAliveTime - time to stay idle in secondspublic void setThreadPriority(int threadPriority)
threadPriority - the thread prioritypublic void setThreadDaemon(boolean threadDaemon)
threadDaemon - true to run as daemonpublic void setWorkQueueSize(int workQueueSize)
size - the queue size before blocks, or -1 default
to indicate no upper boundpublic void setRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
CallerRunsPolicy.rejectedExecutionHandler - the handler to usepublic void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic boolean isSingleton()
isSingleton in interface org.springframework.beans.factory.FactoryBeanpublic java.lang.Object getObject()
throws java.lang.Exception
getObject in interface org.springframework.beans.factory.FactoryBeaninstance.java.lang.Exceptionpublic java.lang.Class getObjectType()
getObjectType in interface org.springframework.beans.factory.FactoryBeanThreadPoolExecutorpublic java.lang.String getPoolName()
public void setPoolName(java.lang.String poolName)
public void destroy()
destroy in interface org.springframework.beans.factory.DisposableBeanCopyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.