- All Superinterfaces:
- Enclosing interface:
ThreadFactorythat creates virtual threads.
Virtual threads created with a builder, or with a
created from a builder, have no
- See Also:
Nested Class Summary
Method SummaryModifier and TypeMethodDescription
allowSetThreadLocals(boolean allow)Sets whether the thread is allowed to set values for its copy of thread-local variables.
inheritInheritableThreadLocals(boolean inherit)Sets whether the thread inherits the initial values of inheritable-thread-local variables.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 scheduler.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
allowSetThreadLocalsThread.Builder.OfVirtual allowSetThreadLocals(boolean allow)Sets 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
getmethod always returns the initial-value.
inheritInheritableThreadLocalsThread.Builder.OfVirtual inheritInheritableThreadLocals(boolean inherit)Sets whether the thread inherits the initial values of inheritable-thread-local variables. The default is to inherit.
The initial values of
InheritableThreadLocals are never inherited when
Thread.Builder.allowSetThreadLocals(boolean)is used to disallow the thread to have its own copy of thread-local variables.
uncaughtExceptionHandlerSets the uncaught exception handler.
schedulerSets the scheduler. The thread will be scheduled by the Java virtual machine with the given scheduler. The scheduler's
executemethod is invoked with tasks of type
Thread.VirtualThreadTask. It may be invoked in the context of a virtual thread. The scheduler should arrange to execute these tasks on a platform thread. Attempting to execute the task on a virtual thread causes an exception to be thrown (see
executemethod may be invoked at sensitive times (e.g. when unparking a thread) so care should be taken to not directly execute the task on the current thread.
scheduler- the scheduler or
nullfor the default scheduler
- this builder