public class ThreadPoolExecutorFactoryBean extends 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 setCorePoolSize(int)
at the time of instance creationkeepAliveTime
:
90 secondsthreadPriority
:
5 (NORM)threadDaemon
:
trueworkQueueSize
:
-1 or less (No upper bound)rejectedExecutionHandler
:
ThreadPoolExecutor.CallerRunsPolicy
Constructor and Description |
---|
ThreadPoolExecutorFactoryBean()
Constructor setting default properties:
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
destroy() |
Object |
getObject() |
Class |
getObjectType() |
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(String poolName) |
void |
setRejectedExecutionHandler(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)
workQueueSize
- the queue size before blocks, or -1 default
to indicate no upper boundpublic void setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler)
CallerRunsPolicy
.rejectedExecutionHandler
- the handler to usepublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean
public Class getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean
ThreadPoolExecutor
public String getPoolName()
public void setPoolName(String poolName)
public void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean
Copyright © 2005–2017 Alfresco Software. All rights reserved.