@CanIgnoreReturnValue @GwtIncompatible public final class ThreadFactoryBuilder extends Object
If no backing thread factory is provided, a default backing thread factory is used as if by
|Constructor and Description|
Creates a new
|Modifier and Type||Method and Description|
Returns a new thread factory using the options supplied during the building process.
Sets daemon or not for new threads created with this ThreadFactory.
Sets the naming format to use when naming threads (
Sets the priority for new threads created with this ThreadFactory.
Sets the backing
public ThreadFactoryBuilder setNameFormat(String nameFormat)
Thread.setName(java.lang.String)) which are created with this ThreadFactory.
String.format(String, Object...)-compatible format String, to which a unique integer (0, 1, etc.) will be supplied as the single parameter. This integer will be unique to the built instance of the ThreadFactory and will be assigned sequentially. For example,
"rpc-pool-%d"will generate thread names like
public ThreadFactoryBuilder setDaemon(boolean daemon)
daemon- whether or not new Threads created with this ThreadFactory will be daemon threads
public ThreadFactoryBuilder setPriority(int priority)
priority- the priority for new Threads created with this ThreadFactory
public ThreadFactoryBuilder setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
Thread.UncaughtExceptionHandlerfor new threads created with this ThreadFactory.
uncaughtExceptionHandler- the uncaught exception handler for new Threads created with this ThreadFactory
public ThreadFactoryBuilder setThreadFactory(ThreadFactory backingThreadFactory)
ThreadFactoryfor new threads created with this ThreadFactory. Threads will be created by invoking #newThread(Runnable) on this backing
backingThreadFactory- the backing
ThreadFactorywhich will be delegated to during thread creation.
@CheckReturnValue public ThreadFactory build()
Copyright © 2010–2019. All rights reserved.