Module java.base
Package java.lang

Interface Thread.Builder

All Known Subinterfaces:
Thread.Builder.OfPlatform, Thread.Builder.OfVirtual
Enclosing class:
Thread

public static sealed interface Thread.Builder permits Thread.Builder.OfPlatform, Thread.Builder.OfVirtual
A builder for Thread and ThreadFactory objects.

Builder defines methods to set Thread properties such as the thread name. This includes properties that would otherwise be inherited. Once set, a Thread or ThreadFactory is created with the following methods:

  • The unstarted method creates a new unstarted Thread to run a task. The Thread's start method must be invoked to schedule the thread to execute.
  • The start method creates a new Thread to run a task and schedules the thread to execute.
  • The factory method creates a ThreadFactory.

A Thread.Builder is not thread safe. The ThreadFactory returned by the builder's factory() method is thread safe.

Unless otherwise specified, passing a null argument to a method in this interface causes a NullPointerException to be thrown.

Since:
21
See Also: