← 返回首页
Thread.Builder (Java SE 26 & JDK 26)
JavaScript is disabled on your browser.
Contents  
  1. Description
  2. Nested Class Summary
  3. Method Summary
  4. Method Details
    1. name(String)
    2. name(String, long)
    3. inheritInheritableThreadLocals(boolean)
    4. uncaughtExceptionHandler(Thread.UncaughtExceptionHandler)
    5. unstarted(Runnable)
    6. start(Runnable)
    7. factory()
Hide sidebar  Show sidebar

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:

Scripting on this page tracks web page traffic, but does not change the content in any way.