Class Executor
- All Implemented Interfaces:
Serializable
,Runnable
- Direct Known Subclasses:
CmdExecutor
,ObjExecutor
If the thread or process cannot be created, is aborted, is externally interrupted, or terminates normally or with failure, a listener function is notified, with an identifier of the event that occurred.
- Since:
- 2007.05.03
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
whether the object/program has been stoppedstatic final int
the object/program was abortedstatic final int
the object/program could not be invoked or failedstatic final int
the runner is idle (no object/program started)static final int
the program was externally interruptedprotected ActionListener
the listener to be notified on termination or failureprotected String
the status message of the object/program invocationstatic final int
the object/program terminated normallystatic final int
the object/program is currently runningprotected int
the status of the object/program invocation -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
FAILED
public static final int FAILEDthe object/program could not be invoked or failed- See Also:
-
OK
public static final int OKthe object/program terminated normally- See Also:
-
RUNNING
public static final int RUNNINGthe object/program is currently running- See Also:
-
ABORTED
public static final int ABORTEDthe object/program was aborted- See Also:
-
INTERRUPTED
public static final int INTERRUPTEDthe program was externally interrupted- See Also:
-
IDLE
public static final int IDLEthe runner is idle (no object/program started)- See Also:
-
listener
the listener to be notified on termination or failure -
aborted
protected volatile boolean abortedwhether the object/program has been stopped -
status
protected volatile int statusthe status of the object/program invocation -
message
the status message of the object/program invocation
-
-
Constructor Details
-
Executor
public Executor()Create an executor.- Since:
- 2023.07.26 (Christian Borgelt)
-
-
Method Details
-
start
public void start()Start the execution as a thread.- Since:
- 2007.05.03 (Christian Borgelt)
-
abort
public void abort()Stop the execution.Note that this function returns immediately after setting a flag (it does not wait for the thread to terminate). Once the thread terminates, the listener function is called with the identifier
ABORTED
.- Since:
- 2007.05.03 (Christian Borgelt)
-
run
public abstract void run()Function for thread execution. -
getStatus
public int getStatus()Get the status of the thread/process invocation.The status is of the runner is
IDLE
before thestart()
function has been called,FAILED
if the thread/process could not be started or the execution failed,RUNNING
while the thread/process is running,ABORTED
if the thread/process was terminated by a call to thestop()
function,INTERRUPTED
if the process was externally interrupted andOK
after the thread/process terminated successfully.- Returns:
- the status of the thread/process invocation
- Since:
- 2007.05.03 (Christian Borgelt)
-
getMessage
Get the status message of the thread/process invocation.This function may yield a proper message string only after the listener function has been called (that is, it may be used in the listener function). However, the same information is provided by the
ActionEvent
passed to the listener.- Returns:
- the status message of the thread/process invocation
- Since:
- 2007.05.03 (Christian Borgelt)
-