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:
Named, Cloneable

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 Details

    • id

      private final long id
      The field for the id record component.
    • priority

      private final int priority
      The field for the priority record component.
    • daemon

      private final boolean daemon
      The field for the daemon record component.
    • name

      @NonNull private final @NonNull String name
      The field for the name record component.
    • threadState

      @NonNull private final Thread.State threadState
      The field for the threadState record component.
  • Constructor Details

    • ThreadSnapshot

      public ThreadSnapshot(long id, int priority, boolean daemon, @NonNull @NonNull String name, @NonNull Thread.State threadState)
      Creates an instance of a ThreadSnapshot record class.
      Parameters:
      id - the value for the id record component
      priority - the value for the priority record component
      daemon - the value for the daemon record component
      name - the value for the name record component
      threadState - the value for the threadState record component
  • Method Details

    • from

      @NonNull public static @NonNull ThreadSnapshot from(@NonNull @NonNull Thread thread)
      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

      Overrides:
      clone in class Object
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public long id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • priority

      public int priority()
      Returns the value of the priority record component.
      Returns:
      the value of the priority record component
    • daemon

      public boolean daemon()
      Returns the value of the daemon record component.
      Returns:
      the value of the daemon record component
    • name

      @NonNull public @NonNull String name()
      Returns the value of the name record component.
      Specified by:
      name in interface Named
      Returns:
      the value of the name record component
    • threadState

      @NonNull public Thread.State threadState()
      Returns the value of the threadState record component.
      Returns:
      the value of the threadState record component