Class ThreadFactoryBuilder
java.lang.Object
dk.cloudcreate.essentials.shared.concurrent.ThreadFactoryBuilder
Builder for a
ThreadFactory to allow setting thread names, auto increment thread numbers, etc.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Create theThreadFactorybased on the builder settingsstatic ThreadFactoryBuilderbuilder()Create a new builderdaemon(boolean daemon) Set if theThread's created by the resultingThreadFactoryare daemon threadsdelegateThreadFactory(ThreadFactory delegateThreadFactory) Set theThreadFactorythat will generate newThread's.nameFormat(String nameFormat) Set the name format for generated thread names.priority(int priority) Set the priority of theThread's generated by the resultingThreadFactoryuncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Set theThread.UncaughtExceptionHandlerfor theThread's created by the resultingThreadFactoryare daemon threads
-
Constructor Details
-
ThreadFactoryBuilder
public ThreadFactoryBuilder()
-
-
Method Details
-
builder
Create a new builder- Returns:
- the new builder
-
build
Create theThreadFactorybased on the builder settings- Returns:
- the
ThreadFactory
-
nameFormat
Set the name format for generated thread names. The format supports using %d as the placeholder for the thread number (every thread created by the resultingThreadFactorywill automatically receive sequential increasing thread number).
Example: "polling-process-%d" or "%d-connection-pool"- Parameters:
nameFormat- the name format- Returns:
- this
ThreadFactoryBuilderinstance
-
delegateThreadFactory
Set theThreadFactorythat will generate newThread's. If none is specified theExecutors.defaultThreadFactory()will be used- Parameters:
delegateThreadFactory- the underlyingThreadFactory- Returns:
- this
ThreadFactoryBuilderinstance
-
priority
Set the priority of theThread's generated by the resultingThreadFactory- Parameters:
priority- the priority of theThread's created. Min value isThread.MIN_PRIORITYand max value isThread.MAX_PRIORITY- Returns:
- this
ThreadFactoryBuilderinstance
-
daemon
Set if theThread's created by the resultingThreadFactoryare daemon threads- Parameters:
daemon- should theThread's created be daemon threads- Returns:
- this
ThreadFactoryBuilderinstance
-
uncaughtExceptionHandler
public ThreadFactoryBuilder uncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Set theThread.UncaughtExceptionHandlerfor theThread's created by the resultingThreadFactoryare daemon threads- Parameters:
uncaughtExceptionHandler- theThread.UncaughtExceptionHandlerfor theThread's created- Returns:
- this
ThreadFactoryBuilderinstance
-