public static class ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder extends ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
ThreadReferencingThreadFactory
. When ready invoke
build()
to construct the new factory.Constructor and Description |
---|
ThreadReferencingThreadFactoryBuilder() |
Modifier and Type | Method and Description |
---|---|
ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder |
appendPoolIdToPrefix(boolean appendPoolIdToPrefix)
Sets if a unique pool id should be appended to the prefix of thread names.
|
ThreadReferencingThreadFactory |
build()
Call to construct the
ThreadReferencingThreadFactory when configuration is ready. |
ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder |
exceptionHandler(ExceptionHandler exceptionHandler)
Sets an
ExceptionHandler to be set for these newly created threads. |
ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder |
onThreadCreation(java.util.function.Consumer<java.lang.Thread> notifyThreadCreation)
Sets a
Consumer which will be provided Thread references as they are created and
before they are started. |
ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder |
threadNamePrefix(java.lang.String threadNamePrefix)
Call to set the prefix for newly created threads names.
|
ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder |
threadPriority(int threadPriority)
Sets the priority associated to the thread.
|
ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder |
useDaemonThreads(boolean useDaemonThreads)
Sets of the created threads should be started with daemon status.
|
public ThreadReferencingThreadFactoryBuilder()
public ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder threadNamePrefix(java.lang.String threadNamePrefix)
ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
"pool-"
. See ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder.appendPoolIdToPrefix(boolean)
for determining the behavior
of a pool ID following this prefix.threadNamePrefix
in class ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
threadNamePrefix
- Prefix for thread name or null
to use the defaultthis
instancepublic ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder appendPoolIdToPrefix(boolean appendPoolIdToPrefix)
ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
appendPoolIdToPrefix
in class ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
appendPoolIdToPrefix
- True to indicate an auto incrementing pool id should be included in the namethis
instancepublic ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder useDaemonThreads(boolean useDaemonThreads)
ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
useDaemonThreads
in class ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
useDaemonThreads
- True if started threads should be set as daemonthis
instancepublic ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder threadPriority(int threadPriority)
ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
Thread.MIN_PRIORITY
and Thread.MAX_PRIORITY
.threadPriority
in class ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
threadPriority
- The priority value to be set on new threadsthis
instancepublic ThreadReferencingThreadFactory.ThreadReferencingThreadFactoryBuilder exceptionHandler(ExceptionHandler exceptionHandler)
ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
ExceptionHandler
to be set for these newly created threads. Typically
ExceptionUtils.setInheritableExceptionHandler(ExceptionHandler)
or
ExceptionUtils.setDefaultExceptionHandler(ExceptionHandler)
are better options.
However this allows you to set an ExceptionHandler
for threads specifically created
from this ThreadFactory.exceptionHandler
in class ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
exceptionHandler
- Handler to be delegated to for errors in produced threadsthis
instancepublic ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder onThreadCreation(java.util.function.Consumer<java.lang.Thread> notifyThreadCreation)
ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
Consumer
which will be provided Thread references as they are created and
before they are started. This can be useful when threads need to be provided to another
library or code to monitor.onThreadCreation
in class ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder
notifyThreadCreation
- Consumer to accept the Threads as they are createdthis
instancepublic ThreadReferencingThreadFactory build()
ThreadReferencingThreadFactory
when configuration is ready.build
in class ConfigurableThreadFactory.ConfigurableThreadFactoryBuilder