OfVirtualis a preview API of the Java platform.
OfVirtualwhen preview features are enabled.
ThreadFactorythat creates virtual threads.
Unless otherwise specified, passing a null argument to a method in
this interface causes a
NullPointerException to be thrown.
Nested Class Summary
Method SummaryModifier and TypeMethodDescription
(boolean allow)Sets whether the thread is allowed to set values for its copy of thread-local variables.
(boolean inherit)Sets whether the thread inherits the initial values of inheritable-thread-local variables from the constructing thread.Sets the thread name.Sets the thread name to be the concatenation of a string prefix and the string representation of a counter value.Sets the uncaught exception handler.
nameSets the thread name.
nameSets the thread name to be the concatenation of a string prefix and the string representation of a counter value. The counter's initial value is
start. It is incremented after a
Threadis created with this builder so that the next thread is named with the new counter value. A
ThreadFactorycreated with this builder is seeded with the current value of the counter. The
ThreadFactoryincrements its copy of the counter after
newThreadis used to create a
allowSetThreadLocalsSets whether the thread is allowed to set values for its copy of thread-local variables. The default is to allow. If not allowed, then any attempt by the thread to set a value for a thread-local with the
UnsupportedOperationException. Any attempt to set the thread's context class loader with
setContextClassLoaderalso throws. The
ThreadLocal.get()method always returns the initial-value when thread locals are not allowed.
inheritInheritableThreadLocalsSets whether the thread inherits the initial values of inheritable-thread-local variables from the constructing thread. The default is to inherit.
The initial values of
InheritableThreadLocals are never inherited when
Thread.Builder.allowSetThreadLocals(boolean)PREVIEW is used to disallow the thread to have its own copy of thread-local variables.
uncaughtExceptionHandlerSets the uncaught exception handler.