public class ThreadPoolManager extends Object
It is a singleton since threads need to be managed vm wide.
This manager forces you to use a bounded queue. By default it uses the current thread for execution when the buffer is full and no free threads can be created.
You can specify the props file to use or pass in a properties object prior to configuration. By default it looks for configuration information in thread_pool.properties.
If set, the Properties object will take precedence.
If a value is not set for a particular pool, the hard coded defaults will be used.
int boundarySize_DEFAULT = 2000; int maximumPoolSize_DEFAULT = 150; int minimumPoolSize_DEFAULT = 4; int keepAliveTime_DEFAULT = 1000 * 60 * 5; boolean abortWhenBlocked = false; String whenBlockedPolicy_DEFAULT = IPoolConfiguration.POLICY_RUN; int startUpSize_DEFAULT = 4;You can configure default settings by specifying a default pool in the properties, ie "cache.ccf"
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PROPS_FILE_NAME
This is the default value.
|
static String |
PROP_NAME_ROOT
the root property name
|
Modifier and Type | Method and Description |
---|---|
protected void |
configure()
Initialize the ThreadPoolManager and create all the pools defined in the configuration.
|
static ThreadPoolManager |
getInstance()
Returns a configured instance of the ThreadPoolManger To specify a configuration file or
Properties object to use call the appropriate setter prior to calling getInstance.
|
ThreadPoolExecutor |
getPool(String name)
Returns a pool by name.
|
ArrayList<String> |
getPoolNames()
Returns the names of all configured pools.
|
static Properties |
getProps() |
static String |
getPropsFileName()
Returns the name of the properties file that we used to initialize the pools.
|
protected PoolConfiguration |
loadConfig(String root)
Configures the default PoolConfiguration settings.
|
static void |
setProps(Properties props)
This will be used if it is not null on initialization.
|
static void |
setPropsFileName(String propsFileName)
Setting this post initialization will have no effect.
|
public static final String DEFAULT_PROPS_FILE_NAME
public static String PROP_NAME_ROOT
public static ThreadPoolManager getInstance()
public ThreadPoolExecutor getPool(String name)
Pools are lazily created.
name
- public ArrayList<String> getPoolNames()
public static void setPropsFileName(String propsFileName)
propsFileName
- The propsFileName to set.public static String getPropsFileName()
public static void setProps(Properties props)
props
- The props to set.public static Properties getProps()
protected void configure()
protected PoolConfiguration loadConfig(String root)
root
- Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.