Class ThreadPoolSupplier.Builder

    • Method Detail

      • 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
      • 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 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

        public ThreadPoolSupplier.Builder virtualEnforced​(boolean enforceVirtualThreads)
        When configured to true, virtual thread executor service must be available, otherwise the built executor would fail to start.
        Parameters:
        enforceVirtualThreads - whether to enforce virtual threads, defaults to false
        Returns:
        updated builder instance
        See Also:
        virtualIfAvailable(boolean)
      • virtualIfAvailable

        public ThreadPoolSupplier.Builder virtualIfAvailable​(boolean useVirtualThreads)
        When configured to true, 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 to false
        Returns:
        updated builder instance