Interface Thread.Builder.OfVirtual
- All Superinterfaces:
Thread.Builder
- Enclosing interface:
Thread.Builder
A builder for creating a virtual
Thread or ThreadFactory
that creates virtual threads.
Unless otherwise specified, passing a null argument to a method in
this interface causes a NullPointerException to be thrown.
- Since:
- 21
- See Also:
-
Nested Class Summary
Nested classes/interfaces declared in interface Thread.Builder
Thread.Builder.OfPlatform, Thread.Builder.OfVirtualModifier and TypeInterfaceDescriptionstatic interfaceA builder for creating a platformThreadorThreadFactorythat creates platform threads.static interfaceA builder for creating a virtualThreadorThreadFactorythat creates virtual threads. -
Method Summary
Modifier and TypeMethodDescriptioninheritInheritableThreadLocals(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.Methods declared in interface Thread.Builder
factory, start, unstartedModifier and TypeMethodDescriptionfactory()Returns aThreadFactoryto create threads from the current state of the builder.Creates a newThreadfrom the current state of the builder and schedules it to execute.Creates a newThreadfrom the current state of the builder to run the given task.
-
Method Details
-
name
Description copied from interface:Thread.BuilderSets the thread name.- Specified by:
namein interfaceThread.Builder- Parameters:
name- thread name- Returns:
- this builder
-
name
Description copied from interface:Thread.BuilderSets the thread name to be the concatenation of a string prefix and the string representation of a counter value. The counter's initial value isstart. It is incremented after aThreadis created with this builder so that the next thread is named with the new counter value. AThreadFactorycreated with this builder is seeded with the current value of the counter. TheThreadFactoryincrements its copy of the counter afternewThreadis used to create aThread.- Specified by:
namein interfaceThread.Builder- Parameters:
prefix- thread name prefixstart- the starting value of the counter- Returns:
- this builder
- Throws:
IllegalArgumentException- if start is negative
-
inheritInheritableThreadLocals
Description copied from interface:Thread.BuilderSets whether the thread inherits the initial values of inheritable-thread-local variables from the constructing thread. The default is to inherit.- Specified by:
inheritInheritableThreadLocalsin interfaceThread.Builder- Parameters:
inherit-trueto inherit,falseto not inherit- Returns:
- this builder
-
uncaughtExceptionHandler
Description copied from interface:Thread.BuilderSets the uncaught exception handler.- Specified by:
uncaughtExceptionHandlerin interfaceThread.Builder- Parameters:
ueh- uncaught exception handler- Returns:
- this builder
-