APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.vm

public Class ThreadContainers

extends Object
Class Inheritance
Imports
java.lang.ref.ReferenceQueue, .WeakReference, java.util.Optional, .Set, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.LongAdder, java.util.stream.Stream, jdk.internal.access.JavaLangAccess, .SharedSecrets

This class consists exclusively of static methods to support groupings of threads.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
ThreadContainers.RootContainer

Root container that "contains" all platform threads not started in a container.

Field Summary

Modifier and TypeField and Description
private static final Set<WeakReference<ThreadContainer>>
private static final JavaLangAccess
private static final ReferenceQueue<Object>
private static final ThreadContainers.RootContainer
private static final boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static Stream<ThreadContainer>
children(ThreadContainer container)

Returns given thread container's "children".

public static ThreadContainer
container(Thread thread)

Returns the thread container that the given Thread is in or the root container if not started in a container.

public static void
deregisterContainer(Object key)

Removes a thread container from being tracked by specifying the key returned when the thread container was registered.

private static void
expungeStaleEntries()

Expunge stale entries from the container registry.

private static ThreadContainer
next(ThreadContainer container)

Returns the thread container that the given thread container encloses.

pack-priv static ThreadContainer
parent(ThreadContainer container)

Returns the parent of the given thread container.

public static Object
registerContainer(ThreadContainer container)

Registers a thread container to be tracked this class, returning a key that is used to remove it from the registry.

public static ThreadContainer
root()

Returns the root thread container.

private static ThreadContainer
top(Thread thread)

Returns the top-most thread container owned by the given thread.

public static boolean
trackAllThreads()

Returns true if all threads are tracked.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONTAINER_REGISTRYback to summary
private static final Set<WeakReference<ThreadContainer>> CONTAINER_REGISTRY
JLAback to summary
private static final JavaLangAccess JLA
QUEUEback to summary
private static final ReferenceQueue<Object> QUEUE
ROOT_CONTAINERback to summary
private static final ThreadContainers.RootContainer ROOT_CONTAINER
TRACK_ALL_THREADSback to summary
private static final boolean TRACK_ALL_THREADS

Constructor Detail

ThreadContainersback to summary
private ThreadContainers()

Method Detail

childrenback to summary
pack-priv static Stream<ThreadContainer> children(ThreadContainer container)

Returns given thread container's "children".

containerback to summary
public static ThreadContainer container(Thread thread)

Returns the thread container that the given Thread is in or the root container if not started in a container.

Exceptions
IllegalStateException:
if the thread has not been started
deregisterContainerback to summary
public static void deregisterContainer(Object key)

Removes a thread container from being tracked by specifying the key returned when the thread container was registered.

expungeStaleEntriesback to summary
private static void expungeStaleEntries()

Expunge stale entries from the container registry.

nextback to summary
private static ThreadContainer next(ThreadContainer container)

Returns the thread container that the given thread container encloses.

parentback to summary
pack-priv static ThreadContainer parent(ThreadContainer container)

Returns the parent of the given thread container. If the container has an owner then its parent is the enclosing container when nested, or the container that the owner is in, when not nested. If the container does not have an owner then the root container is returned, or null if called with the root container.

registerContainerback to summary
public static Object registerContainer(ThreadContainer container)

Registers a thread container to be tracked this class, returning a key that is used to remove it from the registry.

rootback to summary
public static ThreadContainer root()

Returns the root thread container.

topback to summary
private static ThreadContainer top(Thread thread)

Returns the top-most thread container owned by the given thread.

trackAllThreadsback to summary
public static boolean trackAllThreads()

Returns true if all threads are tracked.

jdk.internal.vm back to summary

private abstract Class ThreadContainers.RootContainer

extends ThreadContainer
Class Inheritance
Known Direct Subclasses
jdk.internal.vm.ThreadContainers.RootContainer.TrackingRootContainer, jdk.internal.vm.ThreadContainers.RootContainer.CountingRootContainer

Root container that "contains" all platform threads not started in a container. It may include all virtual threads started directly with the Thread API.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ThreadContainers.RootContainer.CountingRootContainer

Root container that tracks all platform threads and just keeps a count of the virtual threads.

private static class
ThreadContainers.RootContainer.TrackingRootContainer

Root container that tracks all threads.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public String
name()

Overrides jdk.internal.vm.ThreadContainer.name.

Return the name of this container, may be null.

public ThreadContainer
parent()

Overrides jdk.internal.vm.ThreadContainer.parent.

Returns the parent of this container or null if this is the root container.

protected Stream<Thread>
platformThreads()

Returns the platform threads that are not in the container as these threads are considered to be in the root container.

public StackableScope
previous()

Overrides jdk.internal.vm.StackableScope.previous.

Returns the scope that directly encloses this scope, null if none.

public String
toString()

Overrides jdk.internal.vm.ThreadContainer.toString.

Returns a string representation of the object.

Inherited from jdk.internal.vm.ThreadContainer:
addchildrenonExitonStartremovescopedValueBindingsthreadCountthreads

Constructor Detail

RootContainerback to summary
protected RootContainer()

Method Detail

nameback to summary
public String name()

Overrides jdk.internal.vm.ThreadContainer.name.

Doc from jdk.internal.vm.ThreadContainer.name.

Return the name of this container, may be null.

Annotations
@Override
parentback to summary
public ThreadContainer parent()

Overrides jdk.internal.vm.ThreadContainer.parent.

Doc from jdk.internal.vm.ThreadContainer.parent.

Returns the parent of this container or null if this is the root container.

Annotations
@Override
platformThreadsback to summary
protected Stream<Thread> platformThreads()

Returns the platform threads that are not in the container as these threads are considered to be in the root container.

previousback to summary
public StackableScope previous()

Overrides jdk.internal.vm.StackableScope.previous.

Doc from jdk.internal.vm.StackableScope.previous.

Returns the scope that directly encloses this scope, null if none.

Annotations
@Override
toStringback to summary
public String toString()

Overrides jdk.internal.vm.ThreadContainer.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
jdk.internal.vm back to summary

private Class ThreadContainers.RootContainer.CountingRootContainer

extends RootContainer
Class Inheritance

Root container that tracks all platform threads and just keeps a count of the virtual threads.

Field Summary

Modifier and TypeField and Description
private static final LongAdder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
onExit(Thread thread)

Overrides jdk.internal.vm.ThreadContainer.onExit.

Invoked by remove to remove a thread from this container when it terminates (or failed to start).

public void
onStart(Thread thread)

Overrides jdk.internal.vm.ThreadContainer.onStart.

Invoked by add to add a thread to this container before it starts.

public long
threadCount()

Overrides jdk.internal.vm.ThreadContainer.threadCount.

Return a count of the number of threads in this container.

public Stream<Thread>
threads()

Implements abstract jdk.internal.vm.ThreadContainer.threads.

Returns a stream of the live threads in this container.

Inherited from jdk.internal.vm.ThreadContainers.RootContainer:
nameparentplatformThreadsprevioustoString

Field Detail

VTHREAD_COUNTback to summary
private static final LongAdder VTHREAD_COUNT

Constructor Detail

CountingRootContainerback to summary
private CountingRootContainer()

Method Detail

onExitback to summary
public void onExit(Thread thread)

Overrides jdk.internal.vm.ThreadContainer.onExit.

Doc from jdk.internal.vm.ThreadContainer.onExit.

Invoked by remove to remove a thread from this container when it terminates (or failed to start).

Annotations
@Override
onStartback to summary
public void onStart(Thread thread)

Overrides jdk.internal.vm.ThreadContainer.onStart.

Doc from jdk.internal.vm.ThreadContainer.onStart.

Invoked by add to add a thread to this container before it starts.

Annotations
@Override
threadCountback to summary
public long threadCount()

Overrides jdk.internal.vm.ThreadContainer.threadCount.

Doc from jdk.internal.vm.ThreadContainer.threadCount.

Return a count of the number of threads in this container.

Annotations
@Override
threadsback to summary
public Stream<Thread> threads()

Implements abstract jdk.internal.vm.ThreadContainer.threads.

Doc from jdk.internal.vm.ThreadContainer.threads.

Returns a stream of the live threads in this container.

Annotations
@Override
jdk.internal.vm back to summary

private Class ThreadContainers.RootContainer.TrackingRootContainer

extends RootContainer
Class Inheritance

Root container that tracks all threads.

Field Summary

Modifier and TypeField and Description
private static final Set<Thread>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
onExit(Thread thread)

Overrides jdk.internal.vm.ThreadContainer.onExit.

Invoked by remove to remove a thread from this container when it terminates (or failed to start).

public void
onStart(Thread thread)

Overrides jdk.internal.vm.ThreadContainer.onStart.

Invoked by add to add a thread to this container before it starts.

public long
threadCount()

Overrides jdk.internal.vm.ThreadContainer.threadCount.

Return a count of the number of threads in this container.

public Stream<Thread>
threads()

Implements abstract jdk.internal.vm.ThreadContainer.threads.

Returns a stream of the live threads in this container.

Inherited from jdk.internal.vm.ThreadContainers.RootContainer:
nameparentplatformThreadsprevioustoString

Field Detail

VTHREADSback to summary
private static final Set<Thread> VTHREADS

Constructor Detail

TrackingRootContainerback to summary
private TrackingRootContainer()

Method Detail

onExitback to summary
public void onExit(Thread thread)

Overrides jdk.internal.vm.ThreadContainer.onExit.

Doc from jdk.internal.vm.ThreadContainer.onExit.

Invoked by remove to remove a thread from this container when it terminates (or failed to start).

Annotations
@Override
onStartback to summary
public void onStart(Thread thread)

Overrides jdk.internal.vm.ThreadContainer.onStart.

Doc from jdk.internal.vm.ThreadContainer.onStart.

Invoked by add to add a thread to this container before it starts.

Annotations
@Override
threadCountback to summary
public long threadCount()

Overrides jdk.internal.vm.ThreadContainer.threadCount.

Doc from jdk.internal.vm.ThreadContainer.threadCount.

Return a count of the number of threads in this container.

Annotations
@Override
threadsback to summary
public Stream<Thread> threads()

Implements abstract jdk.internal.vm.ThreadContainer.threads.

Doc from jdk.internal.vm.ThreadContainer.threads.

Returns a stream of the live threads in this container.

Annotations
@Override