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

public Class ThreadSnapshot

extends Object
Class Inheritance
Imports
java.util.Arrays, java.util.stream.Stream, jdk.internal.access.JavaLangAccess, .SharedSecrets

Represents a snapshot of information about a Thread.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
private static enum
ThreadSnapshot.OwnedLockType

Represents information about a locking operation.

private static record
private static class
ThreadSnapshot.ThreadLock

Represents a locking operation of a thread at a specific stack depth.

Field Summary

Modifier and TypeField and Description
private ThreadSnapshot.ThreadBlocker
private Object
private int
private Thread
private static final ThreadSnapshot.ThreadLock[]
private static final StackTraceElement[]
private static final JavaLangAccess
private ThreadSnapshot.ThreadLock[]
private String
private Thread
private StackTraceElement[]
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
blockedOn()

Returns the object that the thread is blocked on.

pack-priv Thread
carrierThread()

If the thread is a mounted virtual thread then return its carrier.

private static native ThreadSnapshot
create(Thread thread)

private Object
public static ThreadSnapshot

Returns:

the snapshot or null if the thread is not alive
of
(Thread thread)

Take a snapshot of a Thread to get all information about the thread.

pack-priv Stream<Object>
ownedMonitorsAt(int depth)

Returns the objects that the thread locked at the given depth.

pack-priv boolean
ownsMonitors()

Returns true if the thread owns any object monitors.

pack-priv Object
parkBlocker()

Returns the thread's parkBlocker.

pack-priv Thread
parkBlockerOwner()

Returns the owner of the parkBlocker if the parkBlocker is an AbstractOwnableSynchronizer.

pack-priv StackTraceElement[]
stackTrace()

Returns the thread stack trace.

pack-priv String
threadName()

Returns the thread name.

pack-priv Thread.State
threadState()

Returns the thread state.

pack-priv Object
waitingOn()

Returns the object that the thread is waiting on.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockerback to summary
private ThreadSnapshot.ThreadBlocker blocker
blockerObjectback to summary
private Object blockerObject
blockerTypeOrdinalback to summary
private int blockerTypeOrdinal
carrierThreadback to summary
private Thread carrierThread
EMPTY_LOCKSback to summary
private static final ThreadSnapshot.ThreadLock[] EMPTY_LOCKS
EMPTY_STACKback to summary
private static final StackTraceElement[] EMPTY_STACK
JLAback to summary
private static final JavaLangAccess JLA
locksback to summary
private ThreadSnapshot.ThreadLock[] locks
nameback to summary
private String name
parkBlockerOwnerback to summary
private Thread parkBlockerOwner
stackTraceback to summary
private StackTraceElement[] stackTrace
threadStatusback to summary
private int threadStatus

Constructor Detail

ThreadSnapshotback to summary
private ThreadSnapshot()

Method Detail

blockedOnback to summary
pack-priv Object blockedOn()

Returns the object that the thread is blocked on.

Exceptions
IllegalStateException:
if not in the blocked state
carrierThreadback to summary
pack-priv Thread carrierThread()

If the thread is a mounted virtual thread then return its carrier.

createback to summary
private static native ThreadSnapshot create(Thread thread)
getBlockerback to summary
private Object getBlocker(ThreadSnapshot.BlockerLockType type)
ofback to summary
public static ThreadSnapshot of(Thread thread)

Take a snapshot of a Thread to get all information about the thread.

Returns:ThreadSnapshot

the snapshot or null if the thread is not alive

ownedMonitorsAtback to summary
pack-priv Stream<Object> ownedMonitorsAt(int depth)

Returns the objects that the thread locked at the given depth. The stream will contain a null element for a monitor that has been eliminated.

ownsMonitorsback to summary
pack-priv boolean ownsMonitors()

Returns true if the thread owns any object monitors.

parkBlockerback to summary
pack-priv Object parkBlocker()

Returns the thread's parkBlocker.

parkBlockerOwnerback to summary
pack-priv Thread parkBlockerOwner()

Returns the owner of the parkBlocker if the parkBlocker is an AbstractOwnableSynchronizer.

stackTraceback to summary
pack-priv StackTraceElement[] stackTrace()

Returns the thread stack trace.

threadNameback to summary
pack-priv String threadName()

Returns the thread name.

threadStateback to summary
pack-priv Thread.State threadState()

Returns the thread state.

waitingOnback to summary
pack-priv Object waitingOn()

Returns the object that the thread is waiting on.

Exceptions
IllegalStateException:
if not in the waiting state
jdk.internal.vm back to summary

private final Enum ThreadSnapshot.BlockerLockType

extends Enum<ThreadSnapshot.BlockerLockType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ThreadSnapshot.BlockerLockType
public static final ThreadSnapshot.BlockerLockType
public static final ThreadSnapshot.BlockerLockType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ThreadSnapshot.BlockerLockType
public static ThreadSnapshot.BlockerLockType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

PARK_BLOCKERback to summary
public static final ThreadSnapshot.BlockerLockType PARK_BLOCKER
WAITING_ONback to summary
public static final ThreadSnapshot.BlockerLockType WAITING_ON
WAITING_TO_LOCKback to summary
public static final ThreadSnapshot.BlockerLockType WAITING_TO_LOCK

Constructor Detail

BlockerLockTypeback to summary
private BlockerLockType()

Method Detail

valueOfback to summary
public static ThreadSnapshot.BlockerLockType valueOf(String name)
valuesback to summary
public static ThreadSnapshot.BlockerLockType[] values()
jdk.internal.vm back to summary

private final Enum ThreadSnapshot.OwnedLockType

extends Enum<ThreadSnapshot.OwnedLockType>
Class Inheritance

Represents information about a locking operation.

Field Summary

Modifier and TypeField and Description
public static final ThreadSnapshot.OwnedLockType
public static final ThreadSnapshot.OwnedLockType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ThreadSnapshot.OwnedLockType
public static ThreadSnapshot.OwnedLockType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ELIMINATEDback to summary
public static final ThreadSnapshot.OwnedLockType ELIMINATED
LOCKEDback to summary
public static final ThreadSnapshot.OwnedLockType LOCKED

Constructor Detail

OwnedLockTypeback to summary
private OwnedLockType()

Method Detail

valueOfback to summary
public static ThreadSnapshot.OwnedLockType valueOf(String name)
valuesback to summary
public static ThreadSnapshot.OwnedLockType[] values()
jdk.internal.vm back to summary

private final Record ThreadSnapshot.ThreadBlocker

extends Record
Class Inheritance
Record Components
type:ThreadSnapshot.BlockerLockType 
obj:Object 
owner:Thread 

Field Summary

Modifier and TypeField and Description
private static final ThreadSnapshot.BlockerLockType[]
private final Object
obj

Record Component accessed by obj().

private final Thread
owner

Record Component accessed by owner().

private final ThreadSnapshot.BlockerLockType
type

Record Component accessed by type().

Constructor Summary

AccessConstructor and Description
pack-priv
ThreadBlocker(int typeOrdinal, Object obj, Thread owner)

private

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public Object
obj()

Record Component getter of obj.

public Thread
owner()

Record Component getter of owner.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public ThreadSnapshot.BlockerLockType
type()

Record Component getter of type.

Field Detail

lockTypeValuesback to summary
private static final ThreadSnapshot.BlockerLockType[] lockTypeValues
objback to summary
private final Object obj

Record Component accessed by obj().

ownerback to summary
private final Thread owner

Record Component accessed by owner().

typeback to summary
private final ThreadSnapshot.BlockerLockType type

Record Component accessed by type().

Constructor Detail

ThreadBlockerback to summary
pack-priv ThreadBlocker(int typeOrdinal, Object obj, Thread owner)
ThreadBlockerback to summary
private ThreadBlocker(ThreadSnapshot.BlockerLockType type, Object obj, Thread owner)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

objback to summary
public Object obj()

Record Component getter of obj.

ownerback to summary
public Thread owner()

Record Component getter of owner.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

typeback to summary
public ThreadSnapshot.BlockerLockType type()

Record Component getter of type.

jdk.internal.vm back to summary

private Class ThreadSnapshot.ThreadLock

extends Object
Class Inheritance

Represents a locking operation of a thread at a specific stack depth.

Field Summary

Modifier and TypeField and Description
private int
private static final ThreadSnapshot.OwnedLockType[]
private Object
private ThreadSnapshot.OwnedLockType
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv void
pack-priv Object
pack-priv ThreadSnapshot.OwnedLockType
type()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

depthback to summary
private int depth
lockTypeValuesback to summary
private static final ThreadSnapshot.OwnedLockType[] lockTypeValues
objback to summary
private Object obj
typeback to summary
private ThreadSnapshot.OwnedLockType type
typeOrdinalback to summary
private int typeOrdinal

Constructor Detail

ThreadLockback to summary
private ThreadLock()

Method Detail

depthback to summary
pack-priv int depth()
finishInitback to summary
pack-priv void finishInit()
lockObjectback to summary
pack-priv Object lockObject()
typeback to summary
pack-priv ThreadSnapshot.OwnedLockType type()