public final class ThreadPoolConfig
extends java.lang.Object
 One can get a default ThreadPoolConfig using defaultConfig()
 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 | Method and Description | 
|---|---|
| ThreadPoolConfig | copy()Return a copy of this thread pool config. | 
| static ThreadPoolConfig | defaultConfig()Create new client thread pool configuration instance. | 
| boolean | equals(java.lang.Object o) | 
| int | getCorePoolSize()Get the core thread pool size - the size of the thread pool will never bee smaller than this. | 
| java.lang.ClassLoader | getInitialClassLoader()Get the class loader (if any) to be initially exposed by threads from this pool. | 
| long | getKeepAliveTime(java.util.concurrent.TimeUnit timeUnit)Get the max period of time a thread will wait for a new task to process. | 
| int | getMaxPoolSize()Get max thread pool size. | 
| java.lang.String | getPoolName()Return thread pool name. | 
| int | getPriority()Get priority of the threads in thread pool. | 
| java.util.Queue<java.lang.Runnable> | getQueue()Return a queue that will be used to temporarily store tasks when all threads in the thread pool are busy. | 
| int | getQueueLimit()Get the limit of the queue, where tasks are temporarily stored when all threads are busy. | 
| java.util.concurrent.ThreadFactory | getThreadFactory()Return  ThreadFactorythat will be used to create thread pool threads. | 
| int | hashCode() | 
| boolean | isDaemon()Return  trueif thread pool threads are daemons. | 
| ThreadPoolConfig | setCorePoolSize(int corePoolSize)Set the core thread pool size - the size of the thread pool will never bee smaller than this. | 
| ThreadPoolConfig | setDaemon(boolean isDaemon)Set  trueif thread pool threads are daemons. | 
| ThreadPoolConfig | setInitialClassLoader(java.lang.ClassLoader initialClassLoader)Specifies the context class loader that will be used by threads in this pool. | 
| ThreadPoolConfig | setKeepAliveTime(long time,
                java.util.concurrent.TimeUnit unit)The max period of time a thread will wait for a new task to process. | 
| ThreadPoolConfig | setMaxPoolSize(int maxPoolSize)Set max thread pool size. | 
| ThreadPoolConfig | setPoolName(java.lang.String poolName)Set thread pool name. | 
| ThreadPoolConfig | setPriority(int priority)Set priority of the threads in thread pool. | 
| ThreadPoolConfig | setQueue(java.util.Queue<java.lang.Runnable> queue)Set a queue implementation that will be used to temporarily store tasks when all threads in the thread pool are
 busy. | 
| ThreadPoolConfig | setQueueLimit(int queueLimit)Set the limit of the queue, where tasks are temporarily stored when all threads are busy. | 
| ThreadPoolConfig | setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)Set  ThreadFactorythat will be used to create thread pool threads. | 
| java.lang.String | toString() | 
public static ThreadPoolConfig defaultConfig()
ThreadPoolConfig instance will be
 pre-configured with a default values.public ThreadPoolConfig copy()
public java.util.Queue<java.lang.Runnable> getQueue()
public ThreadPoolConfig setQueue(java.util.Queue<java.lang.Runnable> queue)
queue - queue implementation that will be used to temporarily store tasks when all threads in the thread
              pool are busy.ThreadPoolConfig with the new Queue implementation.public java.util.concurrent.ThreadFactory getThreadFactory()
ThreadFactory that will be used to create thread pool threads.
 
 If ThreadFactory is set, then priority, isDaemon,
 poolName settings will not be considered when creating new threads.
ThreadFactory that will be used to create thread pool threads.public ThreadPoolConfig setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
ThreadFactory that will be used to create thread pool threads.threadFactory - custom ThreadFactory If
                      ThreadFactory is set, then priority, isDaemon, poolName settings will not be considered when creating new threads.ThreadPoolConfig with the new ThreadFactorypublic java.lang.String getPoolName()
public ThreadPoolConfig setPoolName(java.lang.String poolName)
poolName - the thread pool name.ThreadPoolConfig with the new thread pool name.public int getPriority()
Thread.NORM_PRIORITY.public ThreadPoolConfig setPriority(int priority)
Thread.NORM_PRIORITY.priority - of the threads in thread pool.ThreadPoolConfig with the new thread priority.public boolean isDaemon()
true if thread pool threads are daemons. The default is true.true if thread pool threads are daemons.public ThreadPoolConfig setDaemon(boolean isDaemon)
true if thread pool threads are daemons. The default is true.isDaemon - true if thread pool threads are daemons.ThreadPoolConfig with the daemon property set.public int getMaxPoolSize()
Math.max(Runtime.getRuntime().availableProcessors(), 20)public ThreadPoolConfig setMaxPoolSize(int maxPoolSize)
Math.max(Runtime.getRuntime().availableProcessors(), 20).
 Cannot be smaller than 3.
maxPoolSize - the max thread pool size.ThreadPoolConfig with the new max pool size set.public int getCorePoolSize()
The default is 1.
public ThreadPoolConfig setCorePoolSize(int corePoolSize)
The default is 1.
corePoolSize - the core thread pool size - the size of the thread pool will never bee smaller than this.ThreadPoolConfig with the new core pool size set.public int getQueueLimit()
Value less than 0 means unlimited queue. The default is -1.
public ThreadPoolConfig setQueueLimit(int queueLimit)
Value less than 0 means unlimited queue. The default is -1.
queueLimit - the thread pool queue limit. The queueLimit value less than 0 means unlimited queue.ThreadPoolConfig with the new queue limit.public ThreadPoolConfig setKeepAliveTime(long time, java.util.concurrent.TimeUnit unit)
 If the timeout expires and the thread is not a core one (see setCorePoolSize(int),
 setMaxPoolSize(int)) - then the thread will be terminated and removed from the thread pool.
 
The default is 10s.
time - max keep alive timeout. The value less than 0 means no timeout.unit - time unit.ThreadPoolConfig with the new keep alive time.public long getKeepAliveTime(java.util.concurrent.TimeUnit timeUnit)
 If the timeout expires and the thread is not a core one (see setCorePoolSize(int), setMaxPoolSize(int)) - then the thread will be terminated and removed from the thread pool.
 
The default is 10s.
timeUnit - time unit to which the result will be converted.public java.lang.ClassLoader getInitialClassLoader()
If not specified, the class loader of the parent thread that initialized the pool will be used.Authen
public ThreadPoolConfig setInitialClassLoader(java.lang.ClassLoader initialClassLoader)
If not specified, the class loader of the parent thread that initialized the pool will be used.
initialClassLoader - the class loader to be exposed by threads of this pool.ThreadPoolConfig with the class loader set.Thread.getContextClassLoader()public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.ObjectCopyright © 2012–2020 Oracle Corporation. All rights reserved.