Package io.helidon.common.configurable
Class ThreadPoolSupplier.Builder
java.lang.Object
io.helidon.common.configurable.ThreadPoolSupplier.Builder
- All Implemented Interfaces:
Builder<ThreadPoolSupplier.Builder,
,ThreadPoolSupplier> Supplier<ThreadPoolSupplier>
- Enclosing class:
- ThreadPoolSupplier
public static final class ThreadPoolSupplier.Builder
extends Object
implements Builder<ThreadPoolSupplier.Builder,ThreadPoolSupplier>
A fluent API builder for
ThreadPoolSupplier
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the instance from this builder.Load all properties for this thread pool from configuration.corePoolSize
(int corePoolSize) Core pool size of the thread pool executor.daemon
(boolean daemon) Is daemon of the thread pool executor.keepAliveMinutes
(int keepAliveMinutes) Keep alive minutes of the thread pool executor.maxPoolSize
(int maxPoolSize) Max pool size of the thread pool executor.Name of this thread pool executor.prestart
(boolean prestart) Whether to prestart core threads in this thread pool executor.queueCapacity
(int queueCapacity) Queue capacity of the thread pool executor.rejectionHandler
(ThreadPool.RejectionHandler rejectionHandler) Rejection policy of the thread pool executor.threadNamePrefix
(String threadNamePrefix) Name prefix for threads in this thread pool executor.virtualEnforced
(boolean enforceVirtualThreads) When configured totrue
, virtual thread executor service must be available, otherwise the built executor would fail to start.virtualIfAvailable
(boolean useVirtualThreads) When configured totrue
, an unbounded virtual executor service (project Loom) will be used if available.
-
Method Details
-
build
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<ThreadPoolSupplier.Builder,
ThreadPoolSupplier> - Returns:
- instance of the built type
-
corePoolSize
Core pool size of the thread pool executor.- Parameters:
corePoolSize
- seeThreadPoolExecutor.getCorePoolSize()
- Returns:
- updated builder instance
-
maxPoolSize
Max pool size of the thread pool executor.- Parameters:
maxPoolSize
- seeThreadPoolExecutor.getMaximumPoolSize()
- Returns:
- updated builder instance
-
keepAliveMinutes
Keep alive minutes of the thread pool executor.- Parameters:
keepAliveMinutes
- seeThreadPoolExecutor.getKeepAliveTime(TimeUnit)
- Returns:
- updated builder instance
-
queueCapacity
Queue capacity of the thread pool executor.- Parameters:
queueCapacity
- capacity of the queue backing the executor- Returns:
- updated builder instance
-
daemon
Is daemon of the thread pool executor.- Parameters:
daemon
- whether the threads are daemon threads- Returns:
- updated builder instance
-
name
Name of this thread pool executor.- Parameters:
name
- the pool name- Returns:
- updated builder instance
-
rejectionHandler
Rejection policy of the thread pool executor.- Parameters:
rejectionHandler
- the rejection policy- Returns:
- updated builder instance
-
threadNamePrefix
Name prefix for threads in this thread pool executor.- Parameters:
threadNamePrefix
- prefix of a thread name- Returns:
- updated builder instance
-
prestart
Whether to prestart core threads in this thread pool executor.- Parameters:
prestart
- whether to prestart the threads- Returns:
- updated builder instance
-
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 true
Whether 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 true
Whether 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
ThreadPoolExecutor
growth 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
-
virtualEnforced
When configured totrue
, virtual thread executor service must be available, otherwise the built executor would fail to start.- Parameters:
enforceVirtualThreads
- whether to enforce virtual threads, defaults tofalse
- Returns:
- updated builder instance
- See Also:
-
virtualIfAvailable
When configured totrue
, an unbounded virtual executor service (project Loom) will be used if available. This is an experimental feature.If enabled and available, all other configuration options of this executor service are ignored!
- Parameters:
useVirtualThreads
- whether to use virtual threads or not, defaults tofalse
- Returns:
- updated builder instance
-