JavaBean that allows for configuring a JDK 1.5 ThreadPoolExecutor
in bean style (through its "corePoolSize", "maxPoolSize", "keepAliveSeconds", "queueCapacity"
properties) and exposing it as a Spring TaskExecutor.
This class is also well suited for management and monitoring (e.g. through JMX),
providing several useful attributes: "corePoolSize", "maxPoolSize", "keepAliveSeconds"
(all supporting updates at runtime); "poolSize", "activeCount" (for introspection only).

For an alternative, you may set up a ThreadPoolExecutor instance directly using
constructor injection, or use a factory method definition that points to the JDK 1.5
Executors class. To expose such a raw Executor as a
Spring TaskExecutor, simply wrap it with a
ConcurrentTaskExecutor adapter.

NOTE: This class implements Spring's
TaskExecutor interface as well as the JDK 1.5
Executor interface, with the former being the primary
interface, the other just serving as secondary convenience. For this reason, the
exception handling follows the TaskExecutor contract rather than the Executor contract,
in particular regarding the TaskRejectedException.

getCorePoolSize

setMaxPoolSize

Set the ThreadPoolExecutor's maximum pool size.
Default is Integer.MAX_VALUE.

This setting can be modified at runtime, for example through JMX.

getMaxPoolSize

public int getMaxPoolSize()

Return the ThreadPoolExecutor's maximum pool size.

setKeepAliveSeconds

public void setKeepAliveSeconds(int keepAliveSeconds)

Set the ThreadPoolExecutor's keep-alive seconds.
Default is 60.

This setting can be modified at runtime, for example through JMX.

getKeepAliveSeconds

public int getKeepAliveSeconds()

Return the ThreadPoolExecutor's keep-alive seconds.

setAllowCoreThreadTimeOut

public void setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut)

Specify whether to allow core threads to time out. This enables dynamic
growing and shrinking even in combination with a non-zero queue (since
the max pool size will only grow once the queue is full).

Default is "false". Note that this feature is only available on Java 6
or above. On Java 5, consider switching to the backport-concurrent
version of ThreadPoolTaskExecutor which also supports this feature.