Class TaskQueueExecutor.Builder

java.lang.Object
org.omegazero.common.event.TaskQueueExecutor.Builder
Enclosing class:
TaskQueueExecutor

public static class TaskQueueExecutor.Builder extends Object
Builder used to create a TaskQueueExecutor.

A TaskQueueExecutor backed by any queue may be created using TaskQueueExecutor.from(Queue), or with any of the predefined backing queues using TaskQueueExecutor.fromPriority() and TaskQueueExecutor.fromSequential().

Since:
2.6
  • Method Details

    • workerThreads

      public TaskQueueExecutor.Builder workerThreads(int maxWorkerThreadCount)
      Sets the maximum number of worker threads allowed for the TaskQueueExecutor. This method may be called with a negative value to set the maximum number to its absolute value or the number of processors available, whichever is greater. For example, passing -2 sets the maximum number of worker threads to 2, or the number of processors if there are more than 2.

      The default value is 1.

      Parameters:
      maxWorkerThreadCount - The maximum number of worker threads
      Returns:
      This builder
    • daemon

      public TaskQueueExecutor.Builder daemon(boolean daemon)
      Sets whether worker threads of the TaskQueueExecutor should be daemon threads. Setting this to true will not require an explicit call to TaskQueueExecutor.exit(boolean) for the VM to exit.

      The default value is false.

      Parameters:
      daemon - Whether worker threads should be daemon threads
      Returns:
      This builder
    • name

      public TaskQueueExecutor.Builder name(String threadName)
      Sets worker thread name prefix for the TaskQueueExecutor.

      The default value is "TaskExecutor".

      Parameters:
      threadName - The thread name prefix
      Returns:
      This builder
    • build

      public TaskQueueExecutor build()
      Builds a TaskQueueExecutor with previously set parameters.
      Returns:
      The new TaskQueueExecutor
      See Also: