Class BasicThreadFactory.Builder
- java.lang.Object
-
- org.apache.commons.lang3.concurrent.BasicThreadFactory.Builder
-
- All Implemented Interfaces:
Builder<BasicThreadFactory>
- Enclosing class:
- BasicThreadFactory
public static class BasicThreadFactory.Builder extends java.lang.Object implements Builder<BasicThreadFactory>
A builder class for creating instances of
BasicThreadFactory.Using this builder class instances of
BasicThreadFactorycan be created and initialized. The class provides methods that correspond to the configuration options supported byBasicThreadFactory. Method chaining is supported. Refer to the documentation ofBasicThreadFactoryfor a usage example.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.BooleandaemonThe daemon flag.private java.lang.Thread.UncaughtExceptionHandlerexceptionHandlerThe uncaught exception handler.private java.lang.StringnamingPatternThe naming pattern.private java.lang.IntegerpriorityThe priority.private java.util.concurrent.ThreadFactorywrappedFactoryThe wrapped factory.
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BasicThreadFactorybuild()Creates a newBasicThreadFactorywith all configuration options that have been specified by calling methods on this builder.BasicThreadFactory.Builderdaemon(boolean daemon)Sets the daemon flag for the newBasicThreadFactory.BasicThreadFactory.BuildernamingPattern(java.lang.String pattern)Sets the naming pattern to be used by the newBasicThreadFactory.BasicThreadFactory.Builderpriority(int priority)Sets the priority for the threads created by the newBasicThreadFactory.voidreset()Resets this builder.BasicThreadFactory.BuilderuncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)Sets the uncaught exception handler for the threads created by the newBasicThreadFactory.BasicThreadFactory.BuilderwrappedFactory(java.util.concurrent.ThreadFactory factory)Sets theThreadFactoryto be wrapped by the newBasicThreadFactory.
-
-
-
Field Detail
-
wrappedFactory
private java.util.concurrent.ThreadFactory wrappedFactory
The wrapped factory.
-
exceptionHandler
private java.lang.Thread.UncaughtExceptionHandler exceptionHandler
The uncaught exception handler.
-
namingPattern
private java.lang.String namingPattern
The naming pattern.
-
priority
private java.lang.Integer priority
The priority.
-
daemon
private java.lang.Boolean daemon
The daemon flag.
-
-
Method Detail
-
wrappedFactory
public BasicThreadFactory.Builder wrappedFactory(java.util.concurrent.ThreadFactory factory)
Sets theThreadFactoryto be wrapped by the newBasicThreadFactory.- Parameters:
factory- the wrappedThreadFactory(must not be null)- Returns:
- a reference to this
Builder - Throws:
java.lang.NullPointerException- if the passed inThreadFactoryis null
-
namingPattern
public BasicThreadFactory.Builder namingPattern(java.lang.String pattern)
Sets the naming pattern to be used by the newBasicThreadFactory.- Parameters:
pattern- the naming pattern (must not be null)- Returns:
- a reference to this
Builder - Throws:
java.lang.NullPointerException- if the naming pattern is null
-
daemon
public BasicThreadFactory.Builder daemon(boolean daemon)
Sets the daemon flag for the newBasicThreadFactory. If this flag is set to true the new thread factory will create daemon threads.- Parameters:
daemon- the value of the daemon flag- Returns:
- a reference to this
Builder
-
priority
public BasicThreadFactory.Builder priority(int priority)
Sets the priority for the threads created by the newBasicThreadFactory.- Parameters:
priority- the priority- Returns:
- a reference to this
Builder
-
uncaughtExceptionHandler
public BasicThreadFactory.Builder uncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Sets the uncaught exception handler for the threads created by the newBasicThreadFactory.- Parameters:
handler- theUncaughtExceptionHandler(must not be null)- Returns:
- a reference to this
Builder - Throws:
java.lang.NullPointerException- if the exception handler is null
-
reset
public void reset()
Resets this builder. All configuration options are set to default values. Note: If thebuild()method was called, it is not necessary to callreset()explicitly because this is done automatically.
-
build
public BasicThreadFactory build()
Creates a newBasicThreadFactorywith all configuration options that have been specified by calling methods on this builder. After creating the factoryreset()is called.- Specified by:
buildin interfaceBuilder<BasicThreadFactory>- Returns:
- the new
BasicThreadFactory
-
-