BasicThreadFactory.Builder
- public static class org.apache.commons.lang3.concurrent.BasicThreadFactory.Builder implements Builder<BasicThreadFactory>[source]
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.
Constructors
Deprecated. Constructs a new instance. |
- @Deprecated public Builder()[source]
Deprecated: Use
BasicThreadFactory#builder().Constructs a new instance.
Methods
Creates a new |
|
Sets the daemon flag for the new |
|
Sets the daemon flag for the new |
|
Sets the naming pattern to be used by the new |
|
Sets the priority for the threads created by the new |
|
Resets this builder. |
|
Sets the uncaught exception handler for the threads created by the new |
|
Sets the |
- @Override public BasicThreadFactory build()[source]
Creates a new
BasicThreadFactorywith all configuration options that have been specified by calling methods on this builder. After creating the factory#reset()is called.- Returns:
The new
BasicThreadFactory.
- public BasicThreadFactory.Builder daemon()[source]
Sets the daemon flag for the new
BasicThreadFactorytotruecausing a new thread factory to create daemon threads.- Returns:
A reference to this
Builder.- Since:
3.18.0
- public BasicThreadFactory.Builder daemon(boolean daemon)[source]
Sets the daemon flag for the new
BasicThreadFactory. 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.
- public BasicThreadFactory.Builder namingPattern(String namingPattern)[source]
Sets the naming pattern to be used by the new
BasicThreadFactory.The naming pattern is a
format stringthat expects a single argument. This argument is the number of the thread to be created. For instance, if the naming pattern is"MyThread-%d", the first thread created by this factory will be named"MyThread-1", the second one"MyThread-2"and so on.- Parameters:
namingPattern – The naming pattern (must not be
null).- Returns:
A reference to this
Builder.- Throws:
java.lang.NullPointerException – Thrown if the naming pattern is
null.
- public BasicThreadFactory.Builder priority(int priority)[source]
Sets the priority for the threads created by the new
BasicThreadFactory.- Parameters:
priority – The priority.
- Returns:
A reference to this
Builder.
- public void reset()[source]
Resets this builder. All configuration options are set to default values. Note: If the
#build()method was called, it is not necessary to callreset()explicitly because this is done automatically.
- public BasicThreadFactory.Builder uncaughtExceptionHandler(Thread.UncaughtExceptionHandler exceptionHandler)[source]
Sets the uncaught exception handler for the threads created by the new
BasicThreadFactory.- Parameters:
exceptionHandler – The
UncaughtExceptionHandler(must not benull).- Returns:
A reference to this
Builder.- Throws:
java.lang.NullPointerException – Thrown if the exception handler is
null.
- public BasicThreadFactory.Builder wrappedFactory(ThreadFactory factory)[source]
Sets the
ThreadFactoryto be wrapped by the newBasicThreadFactory.- Parameters:
factory – The wrapped
ThreadFactory(must not benull)- Returns:
A reference to this
Builder- Throws:
java.lang.NullPointerException – Thrown if the passed in
ThreadFactoryisnull.