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

public Class SharedThreadContainer

extends ThreadContainer
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
java.lang.invoke.MethodHandles, .VarHandle, java.util.Set, java.util.concurrent.ConcurrentHashMap, java.util.stream.Stream, jdk.internal.access.JavaLangAccess, .SharedSecrets, jdk.internal.invoke.MhUtil

A "shared" thread container. A shared thread container doesn't have an owner and is intended for unstructured uses, e.g. thread pools.

Field Summary

Modifier and TypeField and Description
private static final VarHandle
private volatile boolean
private static final JavaLangAccess
private volatile Object
private final String
private static final VarHandle
private volatile Set<Thread>

Constructor Summary

AccessConstructor and Description
private
SharedThreadContainer(String
the container name, can be null
name
)

Initialize a new SharedThreadContainer.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this container.

public static SharedThreadContainer
create(ThreadContainer parent, String name)

Creates a shared thread container with the given parent and name.

public static SharedThreadContainer
create(String name)

Creates a shared thread container with the given name.

public String
name()

Overrides jdk.internal.vm.ThreadContainer.name.

Return the name of this container, may be null.

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 Thread
owner()

Overrides jdk.internal.vm.StackableScope.owner.

Returns the scope owner or null if not owned.

public void
start(Thread thread)

Starts a thread 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.ThreadContainer:
addchildrenparentremovescopedValueBindingsthreadCounttoString

Field Detail

CLOSEDback to summary
private static final VarHandle CLOSED
closedback to summary
private volatile boolean closed
JLAback to summary
private static final JavaLangAccess JLA

Hides jdk.internal.vm.StackableScope.JLA.

keyback to summary
private volatile Object key
nameback to summary
private final String name
VIRTUAL_THREADSback to summary
private static final VarHandle VIRTUAL_THREADS
virtualThreadsback to summary
private volatile Set<Thread> virtualThreads

Constructor Detail

SharedThreadContainerback to summary
private SharedThreadContainer(String name)

Initialize a new SharedThreadContainer.

Parameters
name:String

the container name, can be null

Method Detail

closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Closes this container. Further attempts to start a thread in this container throw IllegalStateException. This method has no impact on threads that are still running or starting around the time that this method is invoked.

Annotations
@Override
createback to summary
public static SharedThreadContainer create(ThreadContainer parent, String name)

Creates a shared thread container with the given parent and name.

Exceptions
IllegalArgumentException:
if the parent has an owner.
createback to summary
public static SharedThreadContainer create(String name)

Creates a shared thread container with the given name. Its parent will be the root thread container.

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
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
ownerback to summary
public Thread owner()

Overrides jdk.internal.vm.StackableScope.owner.

Doc from jdk.internal.vm.StackableScope.owner.

Returns the scope owner or null if not owned.

Annotations
@Override
startback to summary
public void start(Thread thread)

Starts a thread in this container.

Exceptions
IllegalStateException:
if the container is closed
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