Class BasicThreadFactory.Builder

java.lang.Object
com.helger.commons.concurrent.BasicThreadFactory.Builder
All Implemented Interfaces:
IBuilder<BasicThreadFactory>, IResettableBuilder<BasicThreadFactory>
Enclosing class:
BasicThreadFactory

public static class BasicThreadFactory.Builder extends Object implements IResettableBuilder<BasicThreadFactory>

A builder class for creating instances of BasicThreadFactory.

Using this builder class instances of BasicThreadFactory can be created and initialized. The class provides methods that correspond to the configuration options supported by BasicThreadFactory. Method chaining is supported. Refer to the documentation of BasicThreadFactory for a usage example.

Version:
$Id: BasicThreadFactory.java 1583482 2014-03-31 22:54:57Z niallp $
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • wrappedFactory

      @Nonnull public final BasicThreadFactory.Builder wrappedFactory(@Nonnull ThreadFactory aWrappedFactory)
      Sets the ThreadFactory to be wrapped by the new BasicThreadFactory.
      Parameters:
      aWrappedFactory - the wrapped ThreadFactory (must not be null)
      Returns:
      this for chaining
      Throws:
      NullPointerException - if the passed in ThreadFactory is null
    • threadGroup

      @Nonnull public final BasicThreadFactory.Builder threadGroup(@Nullable ThreadGroup aThreadGroup)
      Sets the ThreadGroup to be used by the default thread factory. If wrappedFactory(ThreadFactory) is used, this setting is useless.
      Parameters:
      aThreadGroup - the ThreadGroup to use. May be null.
      Returns:
      this for chaining
    • uncaughtExceptionHandler

      @Nonnull public final BasicThreadFactory.Builder uncaughtExceptionHandler(@Nonnull Thread.UncaughtExceptionHandler aExceptionHandler)
      Sets the uncaught exception handler for the threads created by the new BasicThreadFactory.
      Parameters:
      aExceptionHandler - the UncaughtExceptionHandler (must not be null)
      Returns:
      this for chaining
      Throws:
      NullPointerException - if the exception handler is null
    • namingPattern

      @Nonnull public final BasicThreadFactory.Builder namingPattern(@Nonnull String sNamingPattern)
      Sets the naming pattern to be used by the new BasicThreadFactory. The formatting is done with String.format(String, Object...) using the thread counter (type long) as the only parameter.
      Parameters:
      sNamingPattern - the naming pattern (must not be null)
      Returns:
      this for chaining
      Throws:
      NullPointerException - if the naming pattern is null
    • priority

      @Nonnull public final BasicThreadFactory.Builder priority(int nPriority)
      Sets the priority for the threads created by the new BasicThreadFactory.
      Parameters:
      nPriority - the priority
      Returns:
      this for chaining
    • daemon

      @Nonnull public final BasicThreadFactory.Builder daemon(boolean bDaemon)
      Sets the daemon flag for the new BasicThreadFactory. If this flag is set to true the new thread factory will create daemon threads.
      Parameters:
      bDaemon - the value of the daemon flag
      Returns:
      this for chaining
    • reset

      public void reset()
      Resets this builder. All configuration options are set to default values. Note: If the build() method was called, it is not necessary to call reset() explicitly because this is done automatically.
      Specified by:
      reset in interface IResettableBuilder<BasicThreadFactory>
    • build

      @Nonnull public BasicThreadFactory build()
      Creates a new BasicThreadFactory with all configuration options that have been specified by calling methods on this builder. After creating the factory reset() is called.
      Specified by:
      build in interface IBuilder<BasicThreadFactory>
      Returns:
      the new BasicThreadFactory