Enum Class ThreadState

java.lang.Object
java.lang.Enum<ThreadState>
com.tnsai.thread.ThreadState
All Implemented Interfaces:
Serializable, Comparable<ThreadState>, Constable

public enum ThreadState extends Enum<ThreadState>
Represents the lifecycle state of an AgentThread.

State transitions:

 CREATED ─────► RUNNING ─────► COMPLETED
    │              │               │
    │              ▼               │
    │           PAUSED ◄───────────┘
    │              │
    ▼              ▼
 CANCELLED ◄── FAILED
 
Since:
0.0.2
  • Enum Constant Details

    • CREATED

      public static final ThreadState CREATED
      Thread has been created but not yet started.
    • RUNNING

      public static final ThreadState RUNNING
      Thread is actively executing.
    • PAUSED

      public static final ThreadState PAUSED
      Thread is paused and can be resumed. State is preserved for later continuation.
    • COMPLETED

      public static final ThreadState COMPLETED
      Thread has completed successfully.
    • FAILED

      public static final ThreadState FAILED
      Thread failed with an error. May be recoverable depending on the error type.
    • CANCELLED

      public static final ThreadState CANCELLED
      Thread was cancelled by user or system.
  • Method Details

    • values

      public static ThreadState[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ThreadState valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getDescription

      public String getDescription()
    • isTerminal

      public boolean isTerminal()
      Check if the thread is in a terminal state.
    • isResumable

      public boolean isResumable()
      Check if the thread can be resumed.
    • isActive

      public boolean isActive()
      Check if the thread is active (running or paused).
    • canPause

      public boolean canPause()
      Check if the thread can be paused.
    • canCancel

      public boolean canCancel()
      Check if the thread can be cancelled.