org.springframework.boot.task

Class TaskSchedulerBuilder



  • public class TaskSchedulerBuilder
    extends Object
    Builder that can be used to configure and create a TaskScheduler. Provides convenience methods to set common ThreadPoolTaskScheduler settings. For advanced configuration, consider using TaskSchedulerCustomizer.

    In a typical auto-configured Spring Boot application this builder is available as a bean and can be injected whenever a TaskScheduler is needed.

    Since:
    2.1.0
    Author:
    Stephane Nicoll
    • Constructor Detail

      • TaskSchedulerBuilder

        public TaskSchedulerBuilder()
    • Method Detail

      • poolSize

        public TaskSchedulerBuilder poolSize(int poolSize)
        Set the maximum allowed number of threads.
        Parameters:
        poolSize - the pool size to set
        Returns:
        a new builder instance
      • threadNamePrefix

        public TaskSchedulerBuilder threadNamePrefix(String threadNamePrefix)
        Set the prefix to use for the names of newly created threads.
        Parameters:
        threadNamePrefix - the thread name prefix to set
        Returns:
        a new builder instance
      • build

        public org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler build()
        Build a new ThreadPoolTaskScheduler instance and configure it using this builder.
        Returns:
        a configured ThreadPoolTaskScheduler instance.
        See Also:
        configure(ThreadPoolTaskScheduler)
      • configure

        public <T extends org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler> T configure(T taskScheduler)
        Configure the provided ThreadPoolTaskScheduler instance using this builder.
        Type Parameters:
        T - the type of task scheduler
        Parameters:
        taskScheduler - the ThreadPoolTaskScheduler to configure
        Returns:
        the task scheduler instance
        See Also:
        build()

Copyright © 2019 Pivotal Software, Inc.. All rights reserved.