All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ForkJoinWorkerThread

  • Nested Class Summary

    Nested Classes

    static interface 

    static enum 

    static interface 

    Interface for handlers invoked when a Thread abruptly terminates due to an uncaught exception.

  • Field Summary

    Fields

    static final int

    The maximum priority that a thread can have.

    static final int

    The minimum priority that a thread can have.

    static final int

    The default priority that is assigned to a thread.

  • Constructor Summary

    Constructors

    Thread()

    Initializes a new platform Thread.

    Initializes a new platform Thread.

    Initializes a new platform Thread.

    Initializes a new platform Thread.

    Initializes a new platform Thread.

    Initializes a new platform Thread so that it has task as its run object, has the specified name as its name, and belongs to the thread group referred to by group.

    Initializes a new platform Thread so that it has task as its run object, has the specified name as its name, and belongs to the thread group referred to by group, and has the specified stack size.

    Thread(ThreadGroup group, Runnable task, String name, long stackSize, boolean inheritInheritableThreadLocals)

    Initializes a new platform Thread so that it has task as its run object, has the specified name as its name, belongs to the thread group referred to by group, has the specified stackSize, and inherits initial values for inheritable thread-local variables if inheritThreadLocals is true.

    Initializes a new platform Thread.

  • Method Summary

    static int

    Returns an estimate of the number of live platform threads in the current thread's thread group and its subgroups.

    final void

    Deprecated, for removal: This API element is subject to removal in a future version.

    clone()

    Throws CloneNotSupportedException as a Thread can not be meaningfully cloned.

    Returns the Thread object for the current thread.

    static void

    dumpStack()

    Prints a stack trace of the current thread to the standard error stream.

    static int

    Copies into the specified array every live platform thread in the current thread's thread group and its subgroups.

    Returns a map of stack traces for all live platform threads.

    Returns the context ClassLoader for this thread.

    Returns the default handler invoked when a thread abruptly terminates due to an uncaught exception.

    long

    getId()

    getName()

    Returns this thread's name.

    final int

    Returns this thread's priority.

    Returns an array of stack trace elements representing the stack dump of this thread.

    getState()

    Returns the state of this thread.

    Returns the thread's thread group or null if the thread has terminated.

    Returns the handler invoked when this thread abruptly terminates due to an uncaught exception.

    static boolean

    Returns true if and only if the current thread holds the monitor lock on the specified object.

    void

    interrupt()

    static boolean

    Tests whether the current thread has been interrupted.

    final boolean

    isAlive()

    Tests if this thread is alive.

    final boolean

    isDaemon()

    Tests if this thread is a daemon thread.

    boolean

    Tests whether this thread has been interrupted.

    final boolean

    isVirtual()

    Returns true if this thread is a virtual thread.

    final void

    join()

    Waits for this thread to terminate.

    final void

    join(long millis)

    Waits at most millis milliseconds for this thread to terminate.

    final void

    join(long millis, int nanos)

    Waits at most millis milliseconds plus nanos nanoseconds for this thread to terminate.

    final boolean

    Waits for this thread to terminate for up to the given waiting duration.

    Returns a builder for creating a platform Thread or ThreadFactory that creates platform threads.

    ofVirtual()

    Returns a builder for creating a virtual Thread or ThreadFactory that creates virtual threads.

    static void

    Indicates that the caller is momentarily unable to progress, until the occurrence of one or more actions on the part of other activities.

    void

    run()

    This method is run by the thread when it executes.

    void

    Sets the context ClassLoader for this thread.

    final void

    setDaemon(boolean on)

    Marks this thread as either a daemon or non-daemon thread.

    static void

    Set the default handler invoked when a thread abruptly terminates due to an uncaught exception, and no other handler has been defined for that thread.

    final void

    Changes the name of this thread to be equal to the argument name.

    final void

    setPriority(int newPriority)

    Changes the priority of this thread.

    void

    Set the handler invoked when this thread abruptly terminates due to an uncaught exception.

    static void

    sleep(long millis)

    Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers.

    static void

    sleep(long millis, int nanos)

    Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds plus the specified number of nanoseconds, subject to the precision and accuracy of system timers and schedulers.

    static void

    Causes the currently executing thread to sleep (temporarily cease execution) for the specified duration, subject to the precision and accuracy of system timers and schedulers.

    void

    start()

    Schedules this thread to begin execution.

    Creates a virtual thread to execute a task and schedules it to execute.

    final long

    threadId()

    Returns the identifier of this Thread.

    toString()

    Returns a string representation of this thread.

    static void

    yield()

    A hint to the scheduler that the current thread is willing to yield its current use of a processor.

    Methods declared in class Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    boolean

    Indicates whether some other object is "equal to" this one.

    protected void

    Deprecated, for removal: This API element is subject to removal in a future version.

    Returns the runtime class of this Object.

    int

    Returns a hash code value for this object.

    final void

    Wakes up a single thread that is waiting on this object's monitor.

    final void

    Wakes up all threads that are waiting on this object's monitor.

    final void

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

    final void

    wait(long timeoutMillis)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

    final void

    wait(long timeoutMillis, int nanos)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

  • Field Details

    • MIN_PRIORITY

    • NORM_PRIORITY

    • MAX_PRIORITY

  • Constructor Details

    • Thread

    • Thread

    • Thread

    • Thread

    • Thread

    • Thread

    • Thread

    • Thread

    • Thread

  • Method Details

    • currentThread

    • yield

    • sleep

    • sleep

    • sleep

    • onSpinWait

    • ofPlatform

    • ofVirtual

    • clone

    • startVirtualThread

    • isVirtual

    • start

    • run

    • interrupt

    • interrupted

    • isInterrupted

    • isAlive

    • setPriority

    • getPriority

    • setName

    • getName

    • getThreadGroup

    • activeCount

    • enumerate

    • join

    • join

    • join

    • join

    • dumpStack

    • setDaemon

    • isDaemon

    • checkAccess

    • toString

    • getContextClassLoader

    • setContextClassLoader

    • holdsLock

    • getStackTrace

    • getAllStackTraces

    • getId

    • threadId

    • getState

    • setDefaultUncaughtExceptionHandler

    • getDefaultUncaughtExceptionHandler

    • getUncaughtExceptionHandler

    • setUncaughtExceptionHandler