Top Description Fields Constructors Methods
jdk.internal.misc

public final Class InnocuousThread

extends Thread
Class Inheritance
Annotations
@SuppressWarnings:removal
Imports
java.security.AccessControlContext, .AccessController, .ProtectionDomain, .PrivilegedAction, java.util.concurrent.atomic.AtomicInteger

A thread that has no permissions, is not a member of any user-defined ThreadGroup and supports the ability to erase ThreadLocals.

Field Summary

Modifier and TypeField and Description
private static final AccessControlContext
ACC

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
private static final long
private volatile boolean
private static final long
private static final long
private static final ThreadGroup
private static final long
private static final AtomicInteger
private static final Unsafe
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
private
InnocuousThread(ThreadGroup group, Runnable target, String name, long stackSize, ClassLoader tccl)

Method Summary

Modifier and TypeMethod and Description
private static Thread
createThread(String name, Runnable target, long stackSize, ClassLoader loader, int priority)

public final void
eraseThreadLocals()

Drops all thread locals (and inherited thread locals).

private static String
public static Thread
newSystemThread(Runnable target)

Returns a new InnocuousThread with an auto-generated thread name.

public static Thread
newSystemThread(String name, Runnable target)

Returns a new InnocuousThread with null context class loader.

public static Thread
newSystemThread(String name, Runnable target, int priority)

Returns a new InnocuousThread with null context class loader.

public static Thread
newSystemThread(String name, Runnable target, long stackSize, int priority)

Returns a new InnocuousThread with null context class loader.

public static Thread
newThread(Runnable target)

Returns a new InnocuousThread with an auto-generated thread name, and its context class loader is set to the system class loader.

public static Thread
newThread(String name, Runnable target)

Returns a new InnocuousThread with its context class loader set to the system class loader.

public static Thread
newThread(String name, Runnable target, int priority)

Returns a new InnocuousThread with its context class loader set to the system class loader.

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

public void
setContextClassLoader(ClassLoader
the context ClassLoader for this Thread, or null indicating the system class loader (or, failing that, the bootstrap class loader)
cl
)

Overrides java.lang.Thread.setContextClassLoader.

Sets the context ClassLoader for this thread.

public void
setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler
the object to use as this thread's uncaught exception handler. If null then this thread has no explicit handler.
x
)

Overrides java.lang.Thread.setUncaughtExceptionHandler.

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

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

ACCback to summary
private static final AccessControlContext ACC

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

CONTEXTCLASSLOADERback to summary
private static final long CONTEXTCLASSLOADER
hasRunback to summary
private volatile boolean hasRun
INHERITABLE_THREAD_LOCALSback to summary
private static final long INHERITABLE_THREAD_LOCALS
INHERITEDACCESSCONTROLCONTEXTback to summary
private static final long INHERITEDACCESSCONTROLCONTEXT
INNOCUOUSTHREADGROUPback to summary
private static final ThreadGroup INNOCUOUSTHREADGROUP
THREAD_LOCALSback to summary
private static final long THREAD_LOCALS
threadNumberback to summary
private static final AtomicInteger threadNumber
UNSAFEback to summary
private static final Unsafe UNSAFE

Constructor Detail

InnocuousThreadback to summary
private InnocuousThread(ThreadGroup group, Runnable target, String name, long stackSize, ClassLoader tccl)

Method Detail

createThreadback to summary
private static Thread createThread(String name, Runnable target, long stackSize, ClassLoader loader, int priority)
eraseThreadLocalsback to summary
public final void eraseThreadLocals()

Drops all thread locals (and inherited thread locals).

newNameback to summary
private static String newName()
newSystemThreadback to summary
public static Thread newSystemThread(Runnable target)

Returns a new InnocuousThread with an auto-generated thread name. Its context class loader is set to null.

newSystemThreadback to summary
public static Thread newSystemThread(String name, Runnable target)

Returns a new InnocuousThread with null context class loader.

newSystemThreadback to summary
public static Thread newSystemThread(String name, Runnable target, int priority)

Returns a new InnocuousThread with null context class loader. Thread priority is set to the given priority.

newSystemThreadback to summary
public static Thread newSystemThread(String name, Runnable target, long stackSize, int priority)

Returns a new InnocuousThread with null context class loader. Thread priority is set to the given priority.

newThreadback to summary
public static Thread newThread(Runnable target)

Returns a new InnocuousThread with an auto-generated thread name, and its context class loader is set to the system class loader.

newThreadback to summary
public static Thread newThread(String name, Runnable target)

Returns a new InnocuousThread with its context class loader set to the system class loader.

newThreadback to summary
public static Thread newThread(String name, Runnable target, int priority)

Returns a new InnocuousThread with its context class loader set to the system class loader. The thread priority will be set to the given priority.

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
setContextClassLoaderback to summary
public void setContextClassLoader(ClassLoader cl)

Overrides java.lang.Thread.setContextClassLoader.

Doc from java.lang.Thread.setContextClassLoader.

Sets the context ClassLoader for this thread.

The context ClassLoader may be set by the creator of the thread for use by code running in this thread when loading classes and resources.

If a security manager is present, its checkPermission method is invoked with a RuntimePermission("setContextClassLoader") permission to see if setting the context ClassLoader is permitted.

Parameters
cl:ClassLoader

the context ClassLoader for this Thread, or null indicating the system class loader (or, failing that, the bootstrap class loader)

Annotations
@Override
setUncaughtExceptionHandlerback to summary
public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler x)

Overrides java.lang.Thread.setUncaughtExceptionHandler.

Doc from java.lang.Thread.setUncaughtExceptionHandler.

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

A thread can take full control of how it responds to uncaught exceptions by having its uncaught exception handler explicitly set. If no such handler is set then the thread's ThreadGroup object acts as its handler.

Parameters
x:Thread.UncaughtExceptionHandler

the object to use as this thread's uncaught exception handler. If null then this thread has no explicit handler.

Annotations
@Override