Package com.tnsai.thread
Enum Class ThreadState
- All Implemented Interfaces:
Serializable,Comparable<ThreadState>,Constable
Represents the lifecycle state of an
AgentThread.
State transitions:
CREATED ─────► RUNNING ─────► COMPLETED
│ │ │
│ ▼ │
│ PAUSED ◄───────────┘
│ │
▼ ▼
CANCELLED ◄── FAILED
- Since:
- 0.0.2
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if the thread can be cancelled.booleancanPause()Check if the thread can be paused.booleanisActive()Check if the thread is active (running or paused).booleanCheck if the thread can be resumed.booleanCheck if the thread is in a terminal state.static ThreadStateReturns the enum constant of this class with the specified name.static ThreadState[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
CREATED
Thread has been created but not yet started. -
RUNNING
Thread is actively executing. -
PAUSED
Thread is paused and can be resumed. State is preserved for later continuation. -
COMPLETED
Thread has completed successfully. -
FAILED
Thread failed with an error. May be recoverable depending on the error type. -
CANCELLED
Thread was cancelled by user or system.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
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.
-