public final class ThreadPoolConfig extends Object
GrizzlyExecutorService.createInstance(org.glassfish.grizzly.threadpool.ThreadPoolConfig)
.
One can get a default Grizzly ThreadPoolConfig using
copy()
and customize it according to the
application specific requirements.
A ThreadPoolConfig object might be customized in a "Builder"-like fashion:
ThreadPoolConfig.defaultConfig()
.setPoolName("App1Pool")
.setCorePoolSize(5)
.setMaxPoolSize(10);
Modifier and Type | Field and Description |
---|---|
protected int |
corePoolSize |
protected ClassLoader |
initialClassLoader |
protected boolean |
isDaemon |
protected long |
keepAliveTimeMillis |
protected int |
maxPoolSize |
protected MemoryManager |
mm |
protected String |
poolName |
protected int |
priority |
protected Queue<Runnable> |
queue |
protected int |
queueLimit |
protected ThreadFactory |
threadFactory |
protected DefaultMonitoringConfig<ThreadPoolProbe> |
threadPoolMonitoringConfig
Thread pool probes
|
protected DelayedExecutor |
transactionMonitor |
protected long |
transactionTimeoutMillis |
protected String poolName
protected int corePoolSize
protected int maxPoolSize
protected int queueLimit
protected long keepAliveTimeMillis
protected ThreadFactory threadFactory
protected int priority
protected boolean isDaemon
protected MemoryManager mm
protected DelayedExecutor transactionMonitor
protected long transactionTimeoutMillis
protected ClassLoader initialClassLoader
protected final DefaultMonitoringConfig<ThreadPoolProbe> threadPoolMonitoringConfig
public static ThreadPoolConfig defaultConfig()
public ThreadPoolConfig copy()
public ThreadPoolConfig setQueue(Queue<Runnable> queue)
queue
- the queue implemenation to useThreadPoolConfig
with the new Queue
implementation.public ThreadFactory getThreadFactory()
ThreadFactory
.
If ThreadFactory
is set - then priority
, isDaemon
,
poolName
settings will not be considered when creating new threads.public ThreadPoolConfig setThreadFactory(ThreadFactory threadFactory)
threadFactory
- custom ThreadFactory
If ThreadFactory
is set - then priority
, isDaemon
,
poolName
settings will not be considered when creating new threads.ThreadPoolConfig
with the new ThreadFactory
public String getPoolName()
public ThreadPoolConfig setPoolName(String poolname)
poolname
- the thread pool name.ThreadPoolConfig
with the new thread pool name.public int getPriority()
public ThreadPoolConfig setPriority(int priority)
public boolean isDaemon()
public ThreadPoolConfig setDaemon(boolean isDaemon)
public int getMaxPoolSize()
public ThreadPoolConfig setMaxPoolSize(int maxPoolSize)
maxPoolSize
- the max thread pool sizeThreadPoolConfig
with the new max pool sizepublic int getCorePoolSize()
public ThreadPoolConfig setCorePoolSize(int corePoolSize)
corePoolSize
- the core thread pool sizeThreadPoolConfig
with the new core pool sizepublic int getQueueLimit()
public ThreadPoolConfig setQueueLimit(int queueLimit)
queueLimit
- the thread-pool queue limit. The queueLimit
value less than 0 means unlimited queue.ThreadPoolConfig
with the new queue limitepublic ThreadPoolConfig setKeepAliveTime(long time, TimeUnit unit)
setCorePoolSize(int)
, setMaxPoolSize(int)
) -
then the thread will be terminated and removed from the thread pool.time
- max keep alive timeout. The value less than 0 means no timeoutunit
- time unitThreadPoolConfig
with the new keep alive timepublic long getKeepAliveTime(TimeUnit timeUnit)
setCorePoolSize(int)
, setMaxPoolSize(int)
) -
then the thread will be terminated and removed from the thread pool.public MemoryManager getMemoryManager()
public ThreadPoolConfig setMemoryManager(MemoryManager mm)
public DefaultMonitoringConfig<ThreadPoolProbe> getInitialMonitoringConfig()
public DelayedExecutor getTransactionMonitor()
public ThreadPoolConfig setTransactionMonitor(DelayedExecutor transactionMonitor)
public long getTransactionTimeout(TimeUnit timeUnit)
public ThreadPoolConfig setTransactionTimeout(long transactionTimeout, TimeUnit timeunit)
public ThreadPoolConfig setTransactionTimeout(DelayedExecutor transactionMonitor, long transactionTimeout, TimeUnit timeunit)
public ClassLoader getInitialClassLoader()
public ThreadPoolConfig setInitialClassLoader(ClassLoader initialClassLoader)
initialClassLoader
- the classloader to be exposed by threads of this pool.ThreadPoolConfig
Thread.getContextClassLoader()
Copyright © 2014 Oracle Corporation. All Rights Reserved.