Class EnhancedQueueExecutor.Builder

java.lang.Object
org.jboss.threads.EnhancedQueueExecutor.Builder
Enclosing class:
EnhancedQueueExecutor

public static final class EnhancedQueueExecutor.Builder extends Object
The builder class for an EnhancedQueueExecutor. All the fields are initialized to sensible defaults for a small thread pool.
  • Constructor Details

    • Builder

      public Builder()
      Construct a new instance.
  • Method Details

    • getThreadFactory

      public ThreadFactory getThreadFactory()
      Get the configured thread factory.
      Returns:
      the configured thread factory (not null)
    • setThreadFactory

      public EnhancedQueueExecutor.Builder setThreadFactory(ThreadFactory threadFactory)
      Set the configured thread factory.
      Parameters:
      threadFactory - the configured thread factory (must not be null)
      Returns:
      this builder
    • getTerminationTask

      public Runnable getTerminationTask()
      Get the termination task. By default, an empty Runnable is used.
      Returns:
      the termination task (not null)
    • setTerminationTask

      public EnhancedQueueExecutor.Builder setTerminationTask(Runnable terminationTask)
      Set the termination task.
      Parameters:
      terminationTask - the termination task (must not be null)
      Returns:
      this builder
    • getCorePoolSize

      public int getCorePoolSize()
      Get the core pool size. This is the size below which new threads will always be created if no idle threads are available. If the pool size reaches the core size but has not yet reached the maximum size, a resistance factor will be applied to each task submission which determines whether the task should be queued or a new thread started.
      Returns:
      the core pool size
      See Also:
    • setCorePoolSize

      public EnhancedQueueExecutor.Builder setCorePoolSize(int coreSize)
      Set the core pool size. If the configured maximum pool size is less than the configured core size, the core size will be reduced to match the maximum size when the thread pool is constructed.
      Parameters:
      coreSize - the core pool size (must be greater than or equal to 0, and less than 2^20)
      Returns:
      this builder
      See Also:
    • getMaximumPoolSize

      public int getMaximumPoolSize()
      Get the maximum pool size. This is the absolute upper limit to the size of the thread pool.
      Returns:
      the maximum pool size
      See Also:
    • setMaximumPoolSize

      public EnhancedQueueExecutor.Builder setMaximumPoolSize(int maxSize)
      Set the maximum pool size. If the configured maximum pool size is less than the configured core size, the core size will be reduced to match the maximum size when the thread pool is constructed.
      Parameters:
      maxSize - the maximum pool size (must be greater than or equal to 0, and less than 2^20)
      Returns:
      this builder
      See Also:
    • getKeepAliveTime

      public Duration getKeepAliveTime()
      Get the thread keep-alive time. This is the amount of time (in the configured time unit) that idle threads will wait for a task before exiting.
      Returns:
      the thread keep-alive time duration
    • getKeepAliveTime

      @Deprecated public long getKeepAliveTime(TimeUnit keepAliveUnits)
      Deprecated.
      Use getKeepAliveTime() instead.
      Get the thread keep-alive time. This is the amount of time (in the configured time unit) that idle threads will wait for a task before exiting.
      Parameters:
      keepAliveUnits - the time keepAliveUnits of the keep-alive time (must not be null)
      Returns:
      the thread keep-alive time
      See Also:
    • setKeepAliveTime

      public EnhancedQueueExecutor.Builder setKeepAliveTime(Duration keepAliveTime)
      Set the thread keep-alive time.
      Parameters:
      keepAliveTime - the thread keep-alive time (must not be null)
    • setKeepAliveTime

      @Deprecated public EnhancedQueueExecutor.Builder setKeepAliveTime(long keepAliveTime, TimeUnit keepAliveUnits)
      Deprecated.
      Set the thread keep-alive time.
      Parameters:
      keepAliveTime - the thread keep-alive time (must be greater than 0)
      keepAliveUnits - the time keepAliveUnits of the keep-alive time (must not be null)
      Returns:
      this builder
      See Also:
    • getGrowthResistance

      public float getGrowthResistance()
      Get the thread pool growth resistance. This is the average fraction of submitted tasks that will be enqueued (instead of causing a new thread to start) when there are no idle threads and the pool size is equal to or greater than the core size (but still less than the maximum size). A value of 0.0 indicates that tasks should not be enqueued until the pool is completely full; a value of 1.0 indicates that tasks should always be enqueued until the queue is completely full.
      Returns:
      the thread pool growth resistance
      See Also:
    • setGrowthResistance

      public EnhancedQueueExecutor.Builder setGrowthResistance(float growthResistance)
      Set the thread pool growth resistance.
      Parameters:
      growthResistance - the thread pool growth resistance (must be in the range 0.0f ≤ n ≤ 1.0f)
      Returns:
      this builder
      See Also:
    • allowsCoreThreadTimeOut

      public boolean allowsCoreThreadTimeOut()
      Determine whether core threads are allowed to time out. A "core thread" is defined as any thread in the pool when the pool size is below the pool's core pool size.
      Returns:
      true if core threads are allowed to time out, false otherwise
      See Also:
    • allowCoreThreadTimeOut

      public EnhancedQueueExecutor.Builder allowCoreThreadTimeOut(boolean allowCoreTimeOut)
      Establish whether core threads are allowed to time out. A "core thread" is defined as any thread in the pool when the pool size is below the pool's core pool size.
      Parameters:
      allowCoreTimeOut - true if core threads are allowed to time out, false otherwise
      Returns:
      this builder
      See Also:
    • getMaximumQueueSize

      public int getMaximumQueueSize()
      Get the maximum queue size. If the queue is full and a task cannot be immediately accepted, rejection will result.
      Returns:
      the maximum queue size
      See Also:
    • setMaximumQueueSize

      public EnhancedQueueExecutor.Builder setMaximumQueueSize(int maxQueueSize)
      Set the maximum queue size. This has no impact when jboss.threads.eqe.unlimited-queue is set.
      Parameters:
      maxQueueSize - the maximum queue size (must be ≥ 0)
      Returns:
      this builder
      See Also:
    • getHandoffExecutor

      public Executor getHandoffExecutor()
      Get the handoff executor.
      Returns:
      the handoff executor (not null)
    • setHandoffExecutor

      public EnhancedQueueExecutor.Builder setHandoffExecutor(Executor handoffExecutor)
      Set the handoff executor.
      Parameters:
      handoffExecutor - the handoff executor (must not be null)
      Returns:
      this builder
    • getExceptionHandler

      public Thread.UncaughtExceptionHandler getExceptionHandler()
      Get the uncaught exception handler.
      Returns:
      the uncaught exception handler (not null)
    • setExceptionHandler

      public EnhancedQueueExecutor.Builder setExceptionHandler(Thread.UncaughtExceptionHandler exceptionHandler)
      Set the uncaught exception handler.
      Parameters:
      exceptionHandler - the uncaught exception handler (must not be null)
      Returns:
      this builder
    • build

      public EnhancedQueueExecutor build()
      Construct the executor from the configured parameters.
      Returns:
      the executor, which will be active and ready to accept tasks (not null)
    • isRegisterMBean

      public boolean isRegisterMBean()
      Determine whether an MBean should automatically be registered for this pool.
      Returns:
      true if an MBean is to be auto-registered; false otherwise
    • setRegisterMBean

      public EnhancedQueueExecutor.Builder setRegisterMBean(boolean registerMBean)
      Establish whether an MBean should automatically be registered for this pool.
      Parameters:
      registerMBean - true if an MBean is to be auto-registered; false otherwise
      Returns:
      this builder
    • getMBeanName

      public String getMBeanName()
      Get the overridden MBean name.
      Returns:
      the overridden MBean name, or null if a default name should be generated
    • setMBeanName

      public EnhancedQueueExecutor.Builder setMBeanName(String mBeanName)
      Set the overridden MBean name.
      Parameters:
      mBeanName - the overridden MBean name, or null if a default name should be generated
      Returns:
      this builder
    • getContextHandler

      public ContextHandler<?> getContextHandler()
      Get the context handler for the user-defined context.
      Returns:
      the context handler for the user-defined context (not null)
    • setContextHandler

      public EnhancedQueueExecutor.Builder setContextHandler(ContextHandler<?> contextHandler)
      Set the context handler for the user-defined context.
      Parameters:
      contextHandler - the context handler for the user-defined context
      Returns:
      this builder