Record Class ThreadSnapshot
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.service.ThreadSnapshot
- Record Components:
id- the numeric id of the running thread.priority- the priority of the thread.daemon- if the thread is a daemon thread.name- the name of the thread.threadState- the current state of the thread.
public record ThreadSnapshot(long id, int priority, boolean daemon, @NonNull String name, Thread.State threadState)
extends Record
implements Named, Cloneable
Contains some basic information about a thread which is known to the jvm. The thread snapshot will not update the
information about the associated thread and only contains its data at a specific point of time. Make sure to get the
thread information again if an updated version of it is required.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanThe field for thedaemonrecord component.private final longThe field for theidrecord component.The field for thenamerecord component.private final intThe field for thepriorityrecord component.private final Thread.StateThe field for thethreadStaterecord component. -
Constructor Summary
ConstructorsConstructorDescriptionThreadSnapshot(long id, int priority, boolean daemon, @NonNull String name, Thread.State threadState) Creates an instance of aThreadSnapshotrecord class. -
Method Summary
Modifier and TypeMethodDescriptionclone()booleandaemon()Returns the value of thedaemonrecord component.final booleanIndicates whether some other object is "equal to" this one.static @NonNull ThreadSnapshotCreates a thread snapshot from the given thread.static @NonNull ThreadSnapshotfrom(@NonNull ThreadInfo info) Creates a thread snapshot from the given thread info.final inthashCode()Returns a hash code value for this object.longid()Returns the value of theidrecord component.name()Returns the value of thenamerecord component.intpriority()Returns the value of thepriorityrecord component.Returns the value of thethreadStaterecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
id
private final long idThe field for theidrecord component. -
priority
private final int priorityThe field for thepriorityrecord component. -
daemon
private final boolean daemonThe field for thedaemonrecord component. -
name
-
threadState
The field for thethreadStaterecord component.
-
-
Constructor Details
-
ThreadSnapshot
public ThreadSnapshot(long id, int priority, boolean daemon, @NonNull @NonNull String name, @NonNull Thread.State threadState) Creates an instance of aThreadSnapshotrecord class.- Parameters:
id- the value for theidrecord componentpriority- the value for thepriorityrecord componentdaemon- the value for thedaemonrecord componentname- the value for thenamerecord componentthreadState- the value for thethreadStaterecord component
-
-
Method Details
-
from
Creates a thread snapshot from the given thread.- Parameters:
thread- the thread to create the snapshot for.- Returns:
- the created thread snapshot for the given thread.
- Throws:
NullPointerException- if the given thread is null.
-
from
Creates a thread snapshot from the given thread info.- Parameters:
info- the thread info to create the thread snapshot for.- Returns:
- the created thread snapshot based on the given thread info.
- Throws:
NullPointerException- if the given thread info is null.
-
clone
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
id
-
priority
-
daemon
-
name
-
threadState
Returns the value of thethreadStaterecord component.- Returns:
- the value of the
threadStaterecord component
-