public interface ThreadPoolConfig extends Config
This is the configuration that defines the properties of a Thread Pool.
Thread Pools may be defined in both server and client side environments. On the server side their details may not be changed after the server has started. On the client side they should be configured before any connections are made.
Modifier and Type | Method and Description |
---|---|
int |
getCoreSize()
Returns the core pool size.
|
long |
getKeepAlive()
Gets the keep alive time.
|
int |
getMaximumSize()
Returns the maximum pool size.
|
String |
getName()
Gets the definition name.
|
int |
getPriority()
Deprecated.
Since 5.8. The thread priority can no longer be configured.
|
int |
getQueueSize()
Returns the queue size.
|
String |
getRejectionHandlerClass()
Returns the rejection handler class name.
|
ThreadPoolListenerConfig |
getThreadPoolListener()
Deprecated.
Since 5.8. Configuration of listeners is no longer supported
and any configured listener will be ignored.
|
ThreadPoolListenerConfig |
removeThreadPoolListener()
Deprecated.
Since 5.8. Configuration of listeners is no longer supported.
|
void |
setCoreSize(int size)
Sets the core pool size.
|
void |
setKeepAlive(long keepAliveTime)
Sets the keep alive time.
|
void |
setMaximumSize(int size)
Sets the maximum pool size.
|
void |
setPriority(int priority)
Deprecated.
Since 5.8. The thread priority can no longer be configured
and this method has no effect.
|
void |
setQueueSize(int size)
Sets the queue size.
|
void |
setRejectionHandlerClass(String className)
Sets the rejection handler class name.
|
ThreadPoolListenerConfig |
setThreadPoolListener(String className,
int lowerThreshold,
int upperThreshold)
Deprecated.
Since 5.8. Configuration of listeners is no longer supported
and any listener configured with this method will be ignored.
|
String getName()
void setCoreSize(int size) throws ConfigException
The core number of threads to have running in the thread pool. Whenever a thread is required a new one will be created until this number is reached, even if there are idle threads already in the pool.
If this is not specified then 5 is assumed.
size
- core pool sizeConfigException
- if unable to set the propertyint getCoreSize()
void setMaximumSize(int size) throws ConfigException
The maximum number of threads that may be created in the thread pool before tasks are queued. Such threads are released immediately after execution.
If this is not specified then 10 is assumed.
size
- the maximum pool sizeConfigException
- if unable to set the propertyint getMaximumSize()
void setQueueSize(int size) throws ConfigException
The queue size. When the max-size is reached then tasks will be queued. If the value is zero then the queue is unbounded. If not 0 then the value must be at least 10.
If this is not specified then 2000 is assumed.
size
- the queue sizeConfigException
- if unable to set the propertyint getQueueSize()
void setKeepAlive(long keepAliveTime) throws ConfigException
Specifies the amount of time to keep inactive threads alive for. This would not apply to core threads.
If this is not specified then 0 is assumed.
keepAliveTime
- the number of milliseconds to keep inactive threads
alive for.ConfigException
- if unable to set the property.long getKeepAlive()
@Deprecated void setPriority(int priority) throws ConfigException
ConfigException
- if the configuration is locked@Deprecated int getPriority()
Thread.NORM_PRIORITY
@Deprecated ThreadPoolListenerConfig setThreadPoolListener(String className, int lowerThreshold, int upperThreshold) throws ConfigException
className
- The name of a class implementing the
ThreadPoolNotificationHandler
interface which will be
instantiated to handle notifications on the thread pool.lowerThreshold
- The size of the thread pool queue at which the
notification handler will be called on the
queueLowerThresholdReached method if the upper threshold has
previously been breached.upperThreshold
- The size of the thread pool queue at which the
notification handler will be called on the
queueUpperThresholdReached method. The method will be called once
only until the queue size drops below the specified lower
threshold. This value must not be greater than the maximum queue
size.ConfigException
- if unable to add listener, possibly because
already configured.@Deprecated ThreadPoolListenerConfig getThreadPoolListener()
@Deprecated ThreadPoolListenerConfig removeThreadPoolListener() throws ConfigException
ConfigException
- if unable to remove listenervoid setRejectionHandlerClass(String className) throws ConfigException
This may be specified to handle tasks that are rejected by the thread pool because it is completely exhausted. If this Is not specified then a default rejection policy is used so that rejected tasks are executed in the calling thread.
className
- the rejection handler class name which must represent a
class of type
ThreadPoolRejectionHandler
.ConfigException
- if unable to set the propertyString getRejectionHandlerClass()
Copyright © 2016 Push Technology Ltd. All Rights Reserved.