Package util

Class Executor

java.lang.Object
util.Executor
All Implemented Interfaces:
Serializable, Runnable
Direct Known Subclasses:
CmdExecutor, ObjExecutor

public abstract class Executor extends Object implements Runnable, Serializable
Abstract class for thread/process execution.

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

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    whether the object/program has been stopped
    static final int
    the object/program was aborted
    static final int
    the object/program could not be invoked or failed
    static final int
    the runner is idle (no object/program started)
    static final int
    the program was externally interrupted
    protected ActionListener
    the listener to be notified on termination or failure
    protected String
    the status message of the object/program invocation
    static final int
    the object/program terminated normally
    static final int
    the object/program is currently running
    protected int
    the status of the object/program invocation
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an executor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Stop the execution.
    Get the status message of the thread/process invocation.
    int
    Get the status of the thread/process invocation.
    abstract void
    run()
    Function for thread execution.
    void
    Start the execution as a thread.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FAILED

      public static final int FAILED
      the object/program could not be invoked or failed
      See Also:
    • OK

      public static final int OK
      the object/program terminated normally
      See Also:
    • RUNNING

      public static final int RUNNING
      the object/program is currently running
      See Also:
    • ABORTED

      public static final int ABORTED
      the object/program was aborted
      See Also:
    • INTERRUPTED

      public static final int INTERRUPTED
      the program was externally interrupted
      See Also:
    • IDLE

      public static final int IDLE
      the runner is idle (no object/program started)
      See Also:
    • listener

      protected transient ActionListener listener
      the listener to be notified on termination or failure
    • aborted

      protected volatile boolean aborted
      whether the object/program has been stopped
    • status

      protected volatile int status
      the status of the object/program invocation
    • message

      protected String 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.
      Specified by:
      run in interface Runnable
      Since:
      2007.05.03 (Christian Borgelt)
    • getStatus

      public int getStatus()
      Get the status of the thread/process invocation.

      The status is of the runner is IDLE before the start() 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 the stop() function, INTERRUPTED if the process was externally interrupted and OK after the thread/process terminated successfully.

      Returns:
      the status of the thread/process invocation
      Since:
      2007.05.03 (Christian Borgelt)
    • getMessage

      public String 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)