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.
- All Implemented Interfaces:
eu.cloudnetservice.common.Named,Cloneable
public record ThreadSnapshot(long id, int priority, boolean daemon, @NonNull String name, Thread.State threadState)
extends Record
implements eu.cloudnetservice.common.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 ThreadSnapshotfrom(@NonNull ThreadInfo info) Creates a thread snapshot from the given thread info.static @NonNull ThreadSnapshotCreates a thread snapshot from the given thread.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
The field for thenamerecord component. -
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
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='. -
id
public long id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
priority
public int priority()Returns the value of thepriorityrecord component.- Returns:
- the value of the
priorityrecord component
-
daemon
public boolean daemon()Returns the value of thedaemonrecord component.- Returns:
- the value of the
daemonrecord component
-
name
Returns the value of thenamerecord component.- Specified by:
namein interfaceeu.cloudnetservice.common.Named- Returns:
- the value of the
namerecord component
-
threadState
Returns the value of thethreadStaterecord component.- Returns:
- the value of the
threadStaterecord component
-