java.lang.Object
org.glassfish.grizzly.threadpool.ThreadPoolConfig
Grizzly thread-pool configuration, which might be used to create and initialize a thread-pool via
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);
- Author:
- Oleksiy Stashok, gustav trede
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected ClassLoader
protected boolean
protected long
protected int
protected MemoryManager
protected String
protected int
protected int
protected ThreadFactory
protected final DefaultMonitoringConfig<ThreadPoolProbe>
Thread pool probesprotected DelayedExecutor
protected long
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
static ThreadPoolConfig
Create new Grizzly thread-pool configuration instance.int
long
getKeepAliveTime
(TimeUnit timeUnit) Returns the max period of time a thread will wait for a new task to process.int
int
getQueue()
int
ReturnsThreadFactory
.long
getTransactionTimeout
(TimeUnit timeUnit) boolean
isDaemon()
setCorePoolSize
(int corePoolSize) setDaemon
(boolean isDaemon) setInitialClassLoader
(ClassLoader initialClassLoader) Specifies the context classloader that will be used by threads in this pool.setKeepAliveTime
(long time, TimeUnit unit) The max period of time a thread will wait for a new task to process.setMaxPoolSize
(int maxPoolSize) setPoolName
(String poolname) setPriority
(int priority) setQueueLimit
(int queueLimit) setThreadFactory
(ThreadFactory threadFactory) setTransactionMonitor
(DelayedExecutor transactionMonitor) setTransactionTimeout
(long transactionTimeout, TimeUnit timeunit) setTransactionTimeout
(DelayedExecutor transactionMonitor, long transactionTimeout, TimeUnit timeunit) toString()
-
Field Details
-
poolName
-
corePoolSize
protected int corePoolSize -
maxPoolSize
protected int maxPoolSize -
queue
-
queueLimit
protected int queueLimit -
keepAliveTimeMillis
protected long keepAliveTimeMillis -
threadFactory
-
priority
protected int priority -
isDaemon
protected boolean isDaemon -
mm
-
transactionMonitor
-
transactionTimeoutMillis
protected long transactionTimeoutMillis -
initialClassLoader
-
threadPoolMonitoringConfig
Thread pool probes
-
-
Method Details
-
defaultConfig
Create new Grizzly thread-pool configuration instance. The returned ThreadPoolConfig instance will be pre-configured with a default values.- Returns:
- the Grizzly thread-pool configuration instance.
-
copy
-
getQueue
- Returns:
- the queue
-
setQueue
- Parameters:
queue
- the queue implemenation to use- Returns:
- the
ThreadPoolConfig
with the newQueue
implementation.
-
getThreadFactory
ReturnsThreadFactory
. IfThreadFactory
is set - thenpriority
,isDaemon
,poolName
settings will not be considered when creating new threads.- Returns:
- the threadFactory
-
setThreadFactory
- Parameters:
threadFactory
- customThreadFactory
IfThreadFactory
is set - thenpriority
,isDaemon
,poolName
settings will not be considered when creating new threads.- Returns:
- the
ThreadPoolConfig
with the newThreadFactory
-
getPoolName
- Returns:
- the poolname
-
setPoolName
- Parameters:
poolname
- the thread pool name.- Returns:
- the
ThreadPoolConfig
with the new thread pool name.
-
getPriority
public int getPriority() -
setPriority
-
isDaemon
public boolean isDaemon() -
setDaemon
-
getMaxPoolSize
public int getMaxPoolSize()- Returns:
- the maxpoolsize
-
setMaxPoolSize
- Parameters:
maxPoolSize
- the max thread pool size- Returns:
- the
ThreadPoolConfig
with the new max pool size
-
getCorePoolSize
public int getCorePoolSize()- Returns:
- the corepoolsize
-
setCorePoolSize
- Parameters:
corePoolSize
- the core thread pool size- Returns:
- the
ThreadPoolConfig
with the new core pool size
-
getQueueLimit
public int getQueueLimit()- Returns:
- the thread-pool queue limit. The queue limit value less than 0 means unlimited queue.
-
setQueueLimit
- Parameters:
queueLimit
- the thread-pool queue limit. The queueLimit value less than 0 means unlimited queue.- Returns:
- the
ThreadPoolConfig
with the new queue limite
-
setKeepAliveTime
The max period of time a thread will wait for a new task to process. If the timeout expires and the thread is not a core one (seesetCorePoolSize(int)
,setMaxPoolSize(int)
) - then the thread will be terminated and removed from the thread pool.- Parameters:
time
- max keep alive timeout. The value less than 0 means no timeoutunit
- time unit- Returns:
- the
ThreadPoolConfig
with the new keep alive time
-
getKeepAliveTime
Returns the max period of time a thread will wait for a new task to process. If the timeout expires and the thread is not a core one (seesetCorePoolSize(int)
,setMaxPoolSize(int)
) - then the thread will be terminated and removed from the thread pool.- Returns:
- the keep-alive timeout, the value less than 0 means no timeout
-
getMemoryManager
-
setMemoryManager
-
getInitialMonitoringConfig
-
getTransactionMonitor
-
setTransactionMonitor
-
getTransactionTimeout
-
setTransactionTimeout
-
setTransactionTimeout
public ThreadPoolConfig setTransactionTimeout(DelayedExecutor transactionMonitor, long transactionTimeout, TimeUnit timeunit) -
getInitialClassLoader
- Returns:
- the classloader (if any) to be initially exposed by threads from this pool.
- Since:
- 2.3
-
setInitialClassLoader
Specifies the context classloader that will be used by threads in this pool. If not specified, the classloader of the parent thread that initialized the pool will be used.- Parameters:
initialClassLoader
- the classloader to be exposed by threads of this pool.- Returns:
- the
ThreadPoolConfig
- Since:
- 2.3
- See Also:
-
toString
-