Package io.helidon.common.configurable
Class ThreadPoolSupplier.Builder
- java.lang.Object
-
- io.helidon.common.configurable.ThreadPoolSupplier.Builder
-
- All Implemented Interfaces:
Builder<ThreadPoolSupplier>,Supplier<ThreadPoolSupplier>
- Enclosing class:
- ThreadPoolSupplier
public static final class ThreadPoolSupplier.Builder extends Object implements Builder<ThreadPoolSupplier>
A fluent API builder forThreadPoolSupplier.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThreadPoolSupplierbuild()Build the instance from this builder.ThreadPoolSupplier.Builderconfig(Config config)Load all properties for this thread pool from configuration.ThreadPoolSupplier.BuildercorePoolSize(int corePoolSize)Core pool size of the thread pool executor.ThreadPoolSupplier.Builderdaemon(boolean daemon)Is daemon of the thread pool executor.ThreadPoolSupplier.BuilderkeepAliveMinutes(int keepAliveMinutes)Keep alive minutes of the thread pool executor.ThreadPoolSupplier.BuildermaxPoolSize(int maxPoolSize)Max pool size of the thread pool executor.ThreadPoolSupplier.Buildername(String name)Name of this thread pool executor.ThreadPoolSupplier.Builderprestart(boolean prestart)Whether to prestart core threads in this thread pool executor.ThreadPoolSupplier.BuilderqueueCapacity(int queueCapacity)Queue capacity of the thread pool executor.ThreadPoolSupplier.BuilderrejectionHandler(ThreadPool.RejectionHandler rejectionHandler)Rejection policy of the thread pool executor.ThreadPoolSupplier.BuilderthreadNamePrefix(String threadNamePrefix)Name prefix for threads in this thread pool executor.
-
-
-
Method Detail
-
build
public ThreadPoolSupplier build()
Description copied from interface:BuilderBuild the instance from this builder.- Specified by:
buildin interfaceBuilder<ThreadPoolSupplier>- Returns:
- instance of the built type
-
corePoolSize
public ThreadPoolSupplier.Builder corePoolSize(int corePoolSize)
Core pool size of the thread pool executor.- Parameters:
corePoolSize- seeThreadPoolExecutor.getCorePoolSize()- Returns:
- updated builder instance
-
maxPoolSize
public ThreadPoolSupplier.Builder maxPoolSize(int maxPoolSize)
Max pool size of the thread pool executor.- Parameters:
maxPoolSize- seeThreadPoolExecutor.getMaximumPoolSize()- Returns:
- updated builder instance
-
keepAliveMinutes
public ThreadPoolSupplier.Builder keepAliveMinutes(int keepAliveMinutes)
Keep alive minutes of the thread pool executor.- Parameters:
keepAliveMinutes- seeThreadPoolExecutor.getKeepAliveTime(TimeUnit)- Returns:
- updated builder instance
-
queueCapacity
public ThreadPoolSupplier.Builder queueCapacity(int queueCapacity)
Queue capacity of the thread pool executor.- Parameters:
queueCapacity- capacity of the queue backing the executor- Returns:
- updated builder instance
-
daemon
public ThreadPoolSupplier.Builder daemon(boolean daemon)
Is daemon of the thread pool executor.- Parameters:
daemon- whether the threads are daemon threads- Returns:
- updated builder instance
-
name
public ThreadPoolSupplier.Builder name(String name)
Name of this thread pool executor.- Parameters:
name- the pool name- Returns:
- updated builder instance
-
rejectionHandler
public ThreadPoolSupplier.Builder rejectionHandler(ThreadPool.RejectionHandler rejectionHandler)
Rejection policy of the thread pool executor.- Parameters:
rejectionHandler- the rejection policy- Returns:
- updated builder instance
-
threadNamePrefix
public ThreadPoolSupplier.Builder threadNamePrefix(String threadNamePrefix)
Name prefix for threads in this thread pool executor.- Parameters:
threadNamePrefix- prefix of a thread name- Returns:
- updated builder instance
-
prestart
public ThreadPoolSupplier.Builder prestart(boolean prestart)
Whether to prestart core threads in this thread pool executor.- Parameters:
prestart- whether to prestart the threads- Returns:
- updated builder instance
-
config
public ThreadPoolSupplier.Builder config(Config config)
Load all properties for this thread pool from configuration.Optional Configuration Parameters key default value description core-pool-size 10 The number of threads to keep in the pool. max-pool-size 50 The maximum number of threads to allow in the pool. keep-alive-minutes 3 When the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating. queue-capacity 10000 The maximum number of tasks that the queue can contain before new tasks are rejected. is-daemon trueWhether or not all threads in the pool should be set as daemon. thread-name-prefix "helidon-"The prefix used to generate names for new threads. should-prestart trueWhether or not all core threads should be started when the pool is created. Experimental Configuration Parameters (subject to change) key default value description growth-threshold 256 The queue size above which pool growth will be considered if the pool is not fixed size. growth-rate 5 The percentage of task submissions that should result in adding a thread, expressed as a value from 0 to 100. For non-zero values the rate is applied when all of the following are true: - the pool size is below the maximum, and
- there are no idle threads, and
- the number of tasks in the queue exceeds the
growthThreshold
For example, a rate of 20 means that while these conditions are met one thread will be added for every 5 submitted tasks.
A rate of 0 selects the default
ThreadPoolExecutorgrowth behavior: a thread is added only when a submitted task is rejected because the queue is full.- Parameters:
config- config located on the key of executor-service- Returns:
- updated builder instance
-
-