Record Class ThreadExecutor

java.lang.Object
java.lang.Record
com.iohao.net.common.kit.concurrent.executor.ThreadExecutor
Record Components:
name - Thread executor name
executor - Thread executor
threadNo - Number

public record ThreadExecutor(String name, Executor executor, int threadNo) extends Record
Thread executor information
Author:
渔民小镇
date:
2023-11-30
  • Constructor Details

    • ThreadExecutor

      public ThreadExecutor(String name, Executor executor, int threadNo)
      Creates an instance of a ThreadExecutor record class.
      Parameters:
      name - the value for the name record component
      executor - the value for the executor record component
      threadNo - the value for the threadNo record component
  • Method Details

    • execute

      public void execute(Runnable command)
      Executes the given command at some time in the future.
      Note that developers need to catch exceptions within the command themselves (in other words,
      do not let the Runnable throw an exception during execution), otherwise it may cause
      executor thread corruption, making the thread unusable.
      
      If you are unsure whether the Runnable will throw an exception during execution, consider using the executeTry method.
      
      Parameters:
      command - Command
      See Also:
    • executeTry

      public void executeTry(Runnable command)
      Executes the given command at some time in the future.
      Parameters:
      command - Command
    • getWorkQueue

      public int getWorkQueue()
    • 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.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • executor

      public Executor executor()
      Returns the value of the executor record component.
      Returns:
      the value of the executor record component
    • threadNo

      public int threadNo()
      Returns the value of the threadNo record component.
      Returns:
      the value of the threadNo record component