Class TaskSchedulerBuilder

java.lang.Object
org.springframework.boot.task.TaskSchedulerBuilder

@Deprecated(since="3.2.0", forRemoval=true) public class TaskSchedulerBuilder extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
since 3.2.0 for removal in 3.4.0 in favor of ThreadPoolTaskSchedulerBuilder
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 Details

    • TaskSchedulerBuilder

      public TaskSchedulerBuilder()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • TaskSchedulerBuilder

      public TaskSchedulerBuilder(Integer poolSize, Boolean awaitTermination, Duration awaitTerminationPeriod, String threadNamePrefix, Set<TaskSchedulerCustomizer> taskSchedulerCustomizers)
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • poolSize

      public TaskSchedulerBuilder poolSize(int poolSize)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the maximum allowed number of threads.
      Parameters:
      poolSize - the pool size to set
      Returns:
      a new builder instance
    • awaitTermination

      public TaskSchedulerBuilder awaitTermination(boolean awaitTermination)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set whether the executor should wait for scheduled tasks to complete on shutdown, not interrupting running tasks and executing all tasks in the queue.
      Parameters:
      awaitTermination - whether the executor needs to wait for the tasks to complete on shutdown
      Returns:
      a new builder instance
      See Also:
    • awaitTerminationPeriod

      public TaskSchedulerBuilder awaitTerminationPeriod(Duration awaitTerminationPeriod)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the maximum time the executor is supposed to block on shutdown. When set, the executor blocks on shutdown in order to wait for remaining tasks to complete their execution before the rest of the container continues to shut down. This is particularly useful if your remaining tasks are likely to need access to other resources that are also managed by the container.
      Parameters:
      awaitTerminationPeriod - the await termination period to set
      Returns:
      a new builder instance
    • threadNamePrefix

      public TaskSchedulerBuilder threadNamePrefix(String threadNamePrefix)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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
    • customizers

      public TaskSchedulerBuilder customizers(TaskSchedulerCustomizer... customizers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the TaskSchedulerCustomizers that should be applied to the ThreadPoolTaskScheduler. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers.
      Parameters:
      customizers - the customizers to set
      Returns:
      a new builder instance
      See Also:
    • customizers

      public TaskSchedulerBuilder customizers(Iterable<TaskSchedulerCustomizer> customizers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the taskSchedulerCustomizers that should be applied to the ThreadPoolTaskScheduler. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers.
      Parameters:
      customizers - the customizers to set
      Returns:
      a new builder instance
      See Also:
    • additionalCustomizers

      public TaskSchedulerBuilder additionalCustomizers(TaskSchedulerCustomizer... customizers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Add taskSchedulerCustomizers that should be applied to the ThreadPoolTaskScheduler. Customizers are applied in the order that they were added after builder configuration has been applied.
      Parameters:
      customizers - the customizers to add
      Returns:
      a new builder instance
      See Also:
    • additionalCustomizers

      public TaskSchedulerBuilder additionalCustomizers(Iterable<TaskSchedulerCustomizer> customizers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Add taskSchedulerCustomizers that should be applied to the ThreadPoolTaskScheduler. Customizers are applied in the order that they were added after builder configuration has been applied.
      Parameters:
      customizers - the customizers to add
      Returns:
      a new builder instance
      See Also:
    • build

      public ThreadPoolTaskScheduler build()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Build a new ThreadPoolTaskScheduler instance and configure it using this builder.
      Returns:
      a configured ThreadPoolTaskScheduler instance.
      See Also:
    • configure

      public <T extends ThreadPoolTaskScheduler> T configure(T taskScheduler)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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: