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

public Class TerminatingThreadLocal<T>

extends CarrierThreadLocal<T>
Class Inheritance
Imports
java.util.Collection, .Collections, .IdentityHashMap

A platform thread-local variable that is notified when a platform thread terminates, and it has been initialized in the terminating thread (or a mounted virtual thread in the case of a carrier thread), and even if it was initialized with a null value.

Field Summary

Modifier and TypeField and Description
public static final TerminatingThreadLocal<Collection<TerminatingThreadLocal<?>>>
REGISTRY

A per-platform-thread registry of TerminatingThreadLocal(s).

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public static void
register(TerminatingThreadLocal<?>
the ThreadLocal to register
tl
)

Register given TerminatingThreadLocal

public void
remove()

Overrides jdk.internal.misc.CarrierThreadLocal.remove.

Removes the current thread's value for this thread-local variable.

public void
set(T value)

Overrides jdk.internal.misc.CarrierThreadLocal.set.

Sets the current thread's copy of this thread-local variable to the specified value.

protected void
threadTerminated(T
current thread's value of this thread-local variable (may be null but only if null value was explicitly initialized)
value
)

Invoked by a thread when terminating and this thread-local has an associated value for the terminating thread (even if that value is null), so that any native resources maintained by the value can be released.

public static void
threadTerminated()

Invokes the TerminatingThreadLocal's threadTerminated() method on all instances registered in current thread.

private static void
unregister(TerminatingThreadLocal<?>
the ThreadLocal to unregister
tl
)

Unregister given TerminatingThreadLocal

Inherited from jdk.internal.misc.CarrierThreadLocal:
get

Field Detail

REGISTRYback to summary
public static final TerminatingThreadLocal<Collection<TerminatingThreadLocal<?>>> REGISTRY

A per-platform-thread registry of TerminatingThreadLocal(s). The registry is itself a TerminatingThreadLocal to keep it reachable until the thread terminates.

Constructor Detail

TerminatingThreadLocalback to summary
public TerminatingThreadLocal()

Method Detail

_threadTerminatedback to summary
private void _threadTerminated()
registerback to summary
public static void register(TerminatingThreadLocal<?> tl)

Register given TerminatingThreadLocal

Parameters
tl:TerminatingThreadLocal<?>

the ThreadLocal to register

removeback to summary
public void remove()

Overrides jdk.internal.misc.CarrierThreadLocal.remove.

Doc from java.lang.ThreadLocal.remove.

Removes the current thread's value for this thread-local variable. If this thread-local variable is subsequently read by the current thread, its value will be reinitialized by invoking its initialValue method, unless its value is set by the current thread in the interim. This may result in multiple invocations of the initialValue method in the current thread.

Annotations
@Override
setback to summary
public void set(T value)

Overrides jdk.internal.misc.CarrierThreadLocal.set.

Doc from java.lang.ThreadLocal.set.

Sets the current thread's copy of this thread-local variable to the specified value. Most subclasses will have no need to override this method, relying solely on the initialValue method to set the values of thread-locals.

Annotations
@Override
threadTerminatedback to summary
protected void threadTerminated(T value)

Invoked by a thread when terminating and this thread-local has an associated value for the terminating thread (even if that value is null), so that any native resources maintained by the value can be released.

Parameters
value:T

current thread's value of this thread-local variable (may be null but only if null value was explicitly initialized)

threadTerminatedback to summary
public static void threadTerminated()

Invokes the TerminatingThreadLocal's threadTerminated() method on all instances registered in current thread.

unregisterback to summary
private static void unregister(TerminatingThreadLocal<?> tl)

Unregister given TerminatingThreadLocal

Parameters
tl:TerminatingThreadLocal<?>

the ThreadLocal to unregister