Top Description Inners Constructors Methods
java.lang

pack-priv Class ThreadBuilders

extends Object
Class Inheritance
Imports
java.lang.Thread.Builder.OfPlatform, .Thread.Builder.OfVirtual, .Thread.UncaughtExceptionHandler, java.lang.invoke.MethodHandles, .VarHandle, java.util.Locale, .Objects, java.util.concurrent.Executor, .ThreadFactory, jdk.internal.misc.Unsafe, jdk.internal.vm.ContinuationSupport

Defines static methods to create platform and virtual thread builders.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ThreadBuilders.BaseThreadBuilder

Base class for Thread.Builder implementations.

private abstract static class
ThreadBuilders.BaseThreadFactory

Base ThreadFactory implementation.

pack-priv static class
ThreadBuilders.BoundVirtualThread

A "virtual thread" that is backed by a platform thread.

pack-priv static class
ThreadBuilders.PlatformThreadBuilder

ThreadBuilder.OfPlatform implementation.

private static class
ThreadBuilders.PlatformThreadFactory

ThreadFactory for platform threads.

pack-priv static class
ThreadBuilders.VirtualThreadBuilder

ThreadBuilder.OfVirtual implementation.

private static class
ThreadBuilders.VirtualThreadFactory

ThreadFactory for virtual threads.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static Thread
newVirtualThread(Executor scheduler, String name, int characteristics, Runnable task)

Creates a new virtual thread to run the given task.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ThreadBuildersback to summary
private ThreadBuilders()

Method Detail

newVirtualThreadback to summary
pack-priv static Thread newVirtualThread(Executor scheduler, String name, int characteristics, Runnable task)

Creates a new virtual thread to run the given task.

java.lang back to summary

private Class ThreadBuilders.BaseThreadBuilder

extends Object
Class Inheritance
Known Direct Subclasses
java.lang.ThreadBuilders.PlatformThreadBuilder, java.lang.ThreadBuilders.VirtualThreadBuilder

Base class for Thread.Builder implementations.

Field Summary

Modifier and TypeField and Description
private int
private long
private String
private Thread.UncaughtExceptionHandler

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv long
pack-priv String
name()

pack-priv String
pack-priv void
pack-priv void
pack-priv void
setName(String prefix, long start)

pack-priv void
pack-priv Thread.UncaughtExceptionHandler
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

characteristicsback to summary
private int characteristics
counterback to summary
private long counter
nameback to summary
private String name
uheback to summary
private Thread.UncaughtExceptionHandler uhe

Constructor Detail

BaseThreadBuilderback to summary
private BaseThreadBuilder()

Method Detail

characteristicsback to summary
pack-priv int characteristics()
counterback to summary
pack-priv long counter()
nameback to summary
pack-priv String name()
nextThreadNameback to summary
pack-priv String nextThreadName()
setInheritInheritableThreadLocalsback to summary
pack-priv void setInheritInheritableThreadLocals(boolean inherit)
setNameback to summary
pack-priv void setName(String name)
setNameback to summary
pack-priv void setName(String prefix, long start)
setUncaughtExceptionHandlerback to summary
pack-priv void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler ueh)
uncaughtExceptionHandlerback to summary
pack-priv Thread.UncaughtExceptionHandler uncaughtExceptionHandler()
java.lang back to summary

private abstract Class ThreadBuilders.BaseThreadFactory

extends Object
implements ThreadFactory
Class Inheritance
All Implemented Interfaces
java.util.concurrent.ThreadFactory
Known Direct Subclasses
java.lang.ThreadBuilders.PlatformThreadFactory, java.lang.ThreadBuilders.VirtualThreadFactory

Base ThreadFactory implementation.

Field Summary

Modifier and TypeField and Description
private final int
private static final VarHandle
private volatile long
private final boolean
private final String
private final Thread.UncaughtExceptionHandler

Constructor Summary

AccessConstructor and Description
pack-priv
BaseThreadFactory(String name, long start, int characteristics, Thread.UncaughtExceptionHandler uhe)

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv String
pack-priv Thread.UncaughtExceptionHandler
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

characteristicsback to summary
private final int characteristics
COUNTback to summary
private static final VarHandle COUNT
countback to summary
private volatile long count
hasCounterback to summary
private final boolean hasCounter
nameback to summary
private final String name
uheback to summary
private final Thread.UncaughtExceptionHandler uhe

Constructor Detail

BaseThreadFactoryback to summary
pack-priv BaseThreadFactory(String name, long start, int characteristics, Thread.UncaughtExceptionHandler uhe)

Method Detail

characteristicsback to summary
pack-priv int characteristics()
nextThreadNameback to summary
pack-priv String nextThreadName()
uncaughtExceptionHandlerback to summary
pack-priv Thread.UncaughtExceptionHandler uncaughtExceptionHandler()
java.lang back to summary

pack-priv final Class ThreadBuilders.BoundVirtualThread

extends BaseVirtualThread
Class Inheritance

A "virtual thread" that is backed by a platform thread. This implementation is intended for platforms that don't have the underlying VM support for continuations. It can also be used for testing.

Field Summary

Modifier and TypeField and Description
private boolean
private final Runnable
private static final Unsafe
U

Constructor Summary

AccessConstructor and Description
pack-priv
BoundVirtualThread(String name, int characteristics, Runnable task)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
park()

Implements abstract java.lang.BaseVirtualThread.park.

Parks the current virtual thread until the parking permit is available or the thread is interrupted.

pack-priv void
parkNanos(long nanos)

Implements abstract java.lang.BaseVirtualThread.parkNanos.

Parks current virtual thread up to the given waiting time until the parking permit is available or the thread is interrupted.

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

public String
toString()

Overrides java.lang.Thread.toString.

Returns a string representation of this thread.

pack-priv void
unpark()

Implements abstract java.lang.BaseVirtualThread.unpark.

Makes available the parking permit to the given this virtual thread.

Field Detail

runInvokedback to summary
private boolean runInvoked
taskback to summary
private final Runnable task
Uback to summary
private static final Unsafe U

Constructor Detail

BoundVirtualThreadback to summary
pack-priv BoundVirtualThread(String name, int characteristics, Runnable task)

Method Detail

parkback to summary
pack-priv void park()

Implements abstract java.lang.BaseVirtualThread.park.

Doc from java.lang.BaseVirtualThread.park.

Parks the current virtual thread until the parking permit is available or the thread is interrupted. The behavior of this method when the current thread is not this thread is not defined.

Annotations
@Override
parkNanosback to summary
pack-priv void parkNanos(long nanos)

Implements abstract java.lang.BaseVirtualThread.parkNanos.

Doc from java.lang.BaseVirtualThread.parkNanos.

Parks current virtual thread up to the given waiting time until the parking permit is available or the thread is interrupted. The behavior of this method when the current thread is not this thread is not defined.

Annotations
@Override
runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Thread.toString.

Doc from java.lang.Thread.toString.

Returns a string representation of this thread. The string representation will usually include the thread's identifier and name. The default implementation for platform threads includes the thread's identifier, name, priority, and the name of the thread group.

Returns:String

a string representation of this thread.

Annotations
@Override
unparkback to summary
pack-priv void unpark()

Implements abstract java.lang.BaseVirtualThread.unpark.

Doc from java.lang.BaseVirtualThread.unpark.

Makes available the parking permit to the given this virtual thread.

Annotations
@Override
java.lang back to summary

pack-priv final Class ThreadBuilders.PlatformThreadBuilder

extends BaseThreadBuilder
implements OfPlatform
Class Inheritance
All Implemented Interfaces
java.lang.Thread.Builder.OfPlatform, java.lang.Thread.Builder

ThreadBuilder.OfPlatform implementation.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private ThreadGroup
private int
private long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Thread.Builder.OfPlatform
daemon(boolean
true to create daemon threads
on
)

Implements java.lang.Thread.Builder.OfPlatform.daemon.

Sets the daemon status.

public ThreadFactory
factory()

Implements java.lang.Thread.Builder.factory.

Returns a ThreadFactory to create threads from the current state of the builder.

public Thread.Builder.OfPlatform
group(ThreadGroup
the thread group
group
)

Implements java.lang.Thread.Builder.OfPlatform.group.

Sets the thread group.

public Thread.Builder.OfPlatform
inheritInheritableThreadLocals(boolean
true to inherit, false to not inherit
inherit
)

Implements java.lang.Thread.Builder.OfPlatform.inheritInheritableThreadLocals.

Sets whether the thread inherits the initial values of inheritable-thread-local variables from the constructing thread.

public Thread.Builder.OfPlatform
name(String
thread name
name
)

Implements java.lang.Thread.Builder.OfPlatform.name.

Sets the thread name.

public Thread.Builder.OfPlatform
name(String
thread name prefix
prefix
,
long
the starting value of the counter
start
)

Implements java.lang.Thread.Builder.OfPlatform.name.

Sets the thread name to be the concatenation of a string prefix and the string representation of a counter value.

pack-priv String
public Thread.Builder.OfPlatform
priority(int
priority
priority
)

Implements java.lang.Thread.Builder.OfPlatform.priority.

Sets the thread priority.

public Thread.Builder.OfPlatform
stackSize(long
the desired stack size
stackSize
)

Implements java.lang.Thread.Builder.OfPlatform.stackSize.

Sets the desired stack size.

public Thread
start(Runnable
the object to run when the thread executes
task
)

Implements java.lang.Thread.Builder.start.

Creates a new Thread from the current state of the builder and schedules it to execute.

public Thread.Builder.OfPlatform
uncaughtExceptionHandler(Thread.UncaughtExceptionHandler
uncaught exception handler
ueh
)

Implements java.lang.Thread.Builder.OfPlatform.uncaughtExceptionHandler.

Sets the uncaught exception handler.

public Thread
unstarted(Runnable
the object to run when the thread executes
task
)

Implements java.lang.Thread.Builder.unstarted.

Creates a new Thread from the current state of the builder to run the given task.

Inherited from java.lang.ThreadBuilders.BaseThreadBuilder:
characteristicscounternamesetInheritInheritableThreadLocalssetNamesetNamesetUncaughtExceptionHandleruncaughtExceptionHandler

Field Detail

daemonback to summary
private boolean daemon
daemonChangedback to summary
private boolean daemonChanged
groupback to summary
private ThreadGroup group
priorityback to summary
private int priority
stackSizeback to summary
private long stackSize

Constructor Detail

PlatformThreadBuilderback to summary
pack-priv PlatformThreadBuilder()

Method Detail

daemonback to summary
public Thread.Builder.OfPlatform daemon(boolean on)

Implements java.lang.Thread.Builder.OfPlatform.daemon.

Doc from java.lang.Thread.Builder.OfPlatform.daemon.

Sets the daemon status.

Parameters
on:boolean

true to create daemon threads

Returns:Thread.Builder.OfPlatform

this builder

Annotations
@Override
factoryback to summary
public ThreadFactory factory()

Implements java.lang.Thread.Builder.factory.

Doc from java.lang.Thread.Builder.factory.

Returns a ThreadFactory to create threads from the current state of the builder. The returned thread factory is safe for use by multiple concurrent threads.

Returns:ThreadFactory

a thread factory to create threads

Annotations
@Override
groupback to summary
public Thread.Builder.OfPlatform group(ThreadGroup group)

Implements java.lang.Thread.Builder.OfPlatform.group.

Doc from java.lang.Thread.Builder.OfPlatform.group.

Sets the thread group.

Parameters
group:ThreadGroup

the thread group

Returns:Thread.Builder.OfPlatform

this builder

Annotations
@Override
inheritInheritableThreadLocalsback to summary
public Thread.Builder.OfPlatform inheritInheritableThreadLocals(boolean inherit)

Implements java.lang.Thread.Builder.OfPlatform.inheritInheritableThreadLocals.

Doc from java.lang.Thread.Builder.inheritInheritableThreadLocals.

Sets whether the thread inherits the initial values of inheritable-thread-local variables from the constructing thread. The default is to inherit.

Parameters
inherit:boolean

true to inherit, false to not inherit

Returns:Thread.Builder.OfPlatform

this builder

Annotations
@Override
nameback to summary
public Thread.Builder.OfPlatform name(String name)

Implements java.lang.Thread.Builder.OfPlatform.name.

Doc from java.lang.Thread.Builder.name.

Sets the thread name.

Parameters
name:String

thread name

Returns:Thread.Builder.OfPlatform

this builder

Annotations
@Override
nameback to summary
public Thread.Builder.OfPlatform name(String prefix, long start)

Implements java.lang.Thread.Builder.OfPlatform.name.

Doc from java.lang.Thread.Builder.name.

Sets 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 Thread is created with this builder so that the next thread is named with the new counter value. A ThreadFactory created with this builder is seeded with the current value of the counter. The ThreadFactory increments its copy of the counter after newThread is used to create a Thread.

Parameters
prefix:String

thread name prefix

start:long

the starting value of the counter

Returns:Thread.Builder.OfPlatform

this builder

Annotations
@Override
nextThreadNameback to summary
pack-priv String nextThreadName()

Overrides java.lang.ThreadBuilders.BaseThreadBuilder.nextThreadName.

Annotations
@Override
priorityback to summary
public Thread.Builder.OfPlatform priority(int priority)

Implements java.lang.Thread.Builder.OfPlatform.priority.

Doc from java.lang.Thread.Builder.OfPlatform.priority.

Sets the thread priority.

Parameters
priority:int

priority

Returns:Thread.Builder.OfPlatform

this builder

Annotations
@Override
stackSizeback to summary
public Thread.Builder.OfPlatform stackSize(long stackSize)

Implements java.lang.Thread.Builder.OfPlatform.stackSize.

Doc from java.lang.Thread.Builder.OfPlatform.stackSize.

Sets the desired stack size.

The stack size is the approximate number of bytes of address space that the Java virtual machine is to allocate for the thread's stack. The effect is highly platform dependent and the Java virtual machine is free to treat the stackSize parameter as a "suggestion". If the value is unreasonably low for the platform then a platform specific minimum may be used. If the value is unreasonably high then a platform specific maximum may be used. A value of zero is always ignored.

Parameters
stackSize:long

the desired stack size

Returns:Thread.Builder.OfPlatform

this builder

Annotations
@Override
startback to summary
public Thread start(Runnable task)

Implements java.lang.Thread.Builder.start.

Doc from java.lang.Thread.Builder.start.

Creates a new Thread from the current state of the builder and schedules it to execute.

Parameters
task:Runnable

the object to run when the thread executes

Returns:Thread

a new started Thread

Annotations
@Override
uncaughtExceptionHandlerback to summary
public Thread.Builder.OfPlatform uncaughtExceptionHandler(Thread.UncaughtExceptionHandler ueh)

Implements java.lang.Thread.Builder.OfPlatform.uncaughtExceptionHandler.

Doc from java.lang.Thread.Builder.uncaughtExceptionHandler.

Sets the uncaught exception handler.

Parameters
ueh:Thread.UncaughtExceptionHandler

uncaught exception handler

Returns:Thread.Builder.OfPlatform

this builder

Annotations
@Override
unstartedback to summary
public Thread unstarted(Runnable task)

Implements java.lang.Thread.Builder.unstarted.

Doc from java.lang.Thread.Builder.unstarted.

Creates a new Thread from the current state of the builder to run the given task. The Thread's start method must be invoked to schedule the thread to execute.

Parameters
task:Runnable

the object to run when the thread executes

Returns:Thread

a new unstarted Thread

Annotations
@Override
java.lang back to summary

private Class ThreadBuilders.PlatformThreadFactory

extends BaseThreadFactory
Class Inheritance

ThreadFactory for platform threads.

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private final ThreadGroup
private final int
private final long

Constructor Summary

AccessConstructor and Description
pack-priv
PlatformThreadFactory(ThreadGroup group, String name, long start, int characteristics, boolean daemonChanged, boolean daemon, int priority, long stackSize, Thread.UncaughtExceptionHandler uhe)

Method Summary

Modifier and TypeMethod and Description
public Thread
newThread(Runnable
a runnable to be executed by new thread instance
task
)

Implements java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

pack-priv String
Inherited from java.lang.ThreadBuilders.BaseThreadFactory:
characteristicsuncaughtExceptionHandler

Field Detail

daemonback to summary
private final boolean daemon
daemonChangedback to summary
private final boolean daemonChanged
groupback to summary
private final ThreadGroup group
priorityback to summary
private final int priority
stackSizeback to summary
private final long stackSize

Constructor Detail

PlatformThreadFactoryback to summary
pack-priv PlatformThreadFactory(ThreadGroup group, String name, long start, int characteristics, boolean daemonChanged, boolean daemon, int priority, long stackSize, Thread.UncaughtExceptionHandler uhe)

Method Detail

newThreadback to summary
public Thread newThread(Runnable task)

Implements java.util.concurrent.ThreadFactory.newThread.

Doc from java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Parameters
task:Runnable

a runnable to be executed by new thread instance

Returns:Thread

constructed thread, or null if the request to create a thread is rejected

Annotations
@Override
nextThreadNameback to summary
pack-priv String nextThreadName()

Overrides java.lang.ThreadBuilders.BaseThreadFactory.nextThreadName.

Annotations
@Override
java.lang back to summary

pack-priv final Class ThreadBuilders.VirtualThreadBuilder

extends BaseThreadBuilder
implements OfVirtual
Class Inheritance
All Implemented Interfaces
java.lang.Thread.Builder.OfVirtual, java.lang.Thread.Builder

ThreadBuilder.OfVirtual implementation.

Field Summary

Modifier and TypeField and Description
private Executor

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ThreadFactory
factory()

Implements java.lang.Thread.Builder.factory.

Returns a ThreadFactory to create threads from the current state of the builder.

public Thread.Builder.OfVirtual
inheritInheritableThreadLocals(boolean
true to inherit, false to not inherit
inherit
)

Implements java.lang.Thread.Builder.OfVirtual.inheritInheritableThreadLocals.

Sets whether the thread inherits the initial values of inheritable-thread-local variables from the constructing thread.

public Thread.Builder.OfVirtual
name(String
thread name
name
)

Implements java.lang.Thread.Builder.OfVirtual.name.

Sets the thread name.

public Thread.Builder.OfVirtual
name(String
thread name prefix
prefix
,
long
the starting value of the counter
start
)

Implements java.lang.Thread.Builder.OfVirtual.name.

Sets the thread name to be the concatenation of a string prefix and the string representation of a counter value.

public Thread
start(Runnable
the object to run when the thread executes
task
)

Implements java.lang.Thread.Builder.start.

Creates a new Thread from the current state of the builder and schedules it to execute.

public Thread.Builder.OfVirtual
uncaughtExceptionHandler(Thread.UncaughtExceptionHandler
uncaught exception handler
ueh
)

Implements java.lang.Thread.Builder.OfVirtual.uncaughtExceptionHandler.

Sets the uncaught exception handler.

public Thread
unstarted(Runnable
the object to run when the thread executes
task
)

Implements java.lang.Thread.Builder.unstarted.

Creates a new Thread from the current state of the builder to run the given task.

Inherited from java.lang.ThreadBuilders.BaseThreadBuilder:
characteristicscounternamenextThreadNamesetInheritInheritableThreadLocalssetNamesetNamesetUncaughtExceptionHandleruncaughtExceptionHandler

Field Detail

schedulerback to summary
private Executor scheduler

Constructor Detail

VirtualThreadBuilderback to summary
pack-priv VirtualThreadBuilder()
VirtualThreadBuilderback to summary
pack-priv VirtualThreadBuilder(Executor scheduler)

Method Detail

factoryback to summary
public ThreadFactory factory()

Implements java.lang.Thread.Builder.factory.

Doc from java.lang.Thread.Builder.factory.

Returns a ThreadFactory to create threads from the current state of the builder. The returned thread factory is safe for use by multiple concurrent threads.

Returns:ThreadFactory

a thread factory to create threads

Annotations
@Override
inheritInheritableThreadLocalsback to summary
public Thread.Builder.OfVirtual inheritInheritableThreadLocals(boolean inherit)

Implements java.lang.Thread.Builder.OfVirtual.inheritInheritableThreadLocals.

Doc from java.lang.Thread.Builder.inheritInheritableThreadLocals.

Sets whether the thread inherits the initial values of inheritable-thread-local variables from the constructing thread. The default is to inherit.

Parameters
inherit:boolean

true to inherit, false to not inherit

Returns:Thread.Builder.OfVirtual

this builder

Annotations
@Override
nameback to summary
public Thread.Builder.OfVirtual name(String name)

Implements java.lang.Thread.Builder.OfVirtual.name.

Doc from java.lang.Thread.Builder.name.

Sets the thread name.

Parameters
name:String

thread name

Returns:Thread.Builder.OfVirtual

this builder

Annotations
@Override
nameback to summary
public Thread.Builder.OfVirtual name(String prefix, long start)

Implements java.lang.Thread.Builder.OfVirtual.name.

Doc from java.lang.Thread.Builder.name.

Sets 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 Thread is created with this builder so that the next thread is named with the new counter value. A ThreadFactory created with this builder is seeded with the current value of the counter. The ThreadFactory increments its copy of the counter after newThread is used to create a Thread.

Parameters
prefix:String

thread name prefix

start:long

the starting value of the counter

Returns:Thread.Builder.OfVirtual

this builder

Annotations
@Override
startback to summary
public Thread start(Runnable task)

Implements java.lang.Thread.Builder.start.

Doc from java.lang.Thread.Builder.start.

Creates a new Thread from the current state of the builder and schedules it to execute.

Parameters
task:Runnable

the object to run when the thread executes

Returns:Thread

a new started Thread

Annotations
@Override
uncaughtExceptionHandlerback to summary
public Thread.Builder.OfVirtual uncaughtExceptionHandler(Thread.UncaughtExceptionHandler ueh)

Implements java.lang.Thread.Builder.OfVirtual.uncaughtExceptionHandler.

Doc from java.lang.Thread.Builder.uncaughtExceptionHandler.

Sets the uncaught exception handler.

Parameters
ueh:Thread.UncaughtExceptionHandler

uncaught exception handler

Returns:Thread.Builder.OfVirtual

this builder

Annotations
@Override
unstartedback to summary
public Thread unstarted(Runnable task)

Implements java.lang.Thread.Builder.unstarted.

Doc from java.lang.Thread.Builder.unstarted.

Creates a new Thread from the current state of the builder to run the given task. The Thread's start method must be invoked to schedule the thread to execute.

Parameters
task:Runnable

the object to run when the thread executes

Returns:Thread

a new unstarted Thread

Annotations
@Override
java.lang back to summary

private Class ThreadBuilders.VirtualThreadFactory

extends BaseThreadFactory
Class Inheritance

ThreadFactory for virtual threads.

Field Summary

Modifier and TypeField and Description
private final Executor

Constructor Summary

AccessConstructor and Description
pack-priv
VirtualThreadFactory(Executor scheduler, String name, long start, int characteristics, Thread.UncaughtExceptionHandler uhe)

Method Summary

Modifier and TypeMethod and Description
public Thread
newThread(Runnable
a runnable to be executed by new thread instance
task
)

Implements java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Inherited from java.lang.ThreadBuilders.BaseThreadFactory:
characteristicsnextThreadNameuncaughtExceptionHandler

Field Detail

schedulerback to summary
private final Executor scheduler

Constructor Detail

VirtualThreadFactoryback to summary
pack-priv VirtualThreadFactory(Executor scheduler, String name, long start, int characteristics, Thread.UncaughtExceptionHandler uhe)

Method Detail

newThreadback to summary
public Thread newThread(Runnable task)

Implements java.util.concurrent.ThreadFactory.newThread.

Doc from java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Parameters
task:Runnable

a runnable to be executed by new thread instance

Returns:Thread

constructed thread, or null if the request to create a thread is rejected

Annotations
@Override