java.lang.Object
java.lang.Thread
de.seggebaeing.sqlanalyzer.logic.util.thread.WorkerThread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
EvaluationThread, GenerationThread

public abstract class WorkerThread extends Thread
Abstract base class for long-running worker threads that coordinate a fixed-size pool of subworkers.

Subclasses implement run() to perform the work, typically using up to poolSize parallel subworkers. When the work completes successfully, they should invoke signalDone.

The aggregated outcome can be obtained via getResult() after a successful run.

Since:
1.0
Author:
Felix Seggebäing
  • Field Details

    • signalDone

      protected final Runnable signalDone
    • poolSize

      protected final int poolSize
  • Constructor Details

    • WorkerThread

      public WorkerThread(String name, int poolSize, Runnable signalDone)
      Constructs a WorkerThread with a name, a maximum subworker pool size, and an optional completion callback.
      Parameters:
      name - the thread name
      poolSize - number of parallel subworkers to use
      signalDone - callback to invoke on successful completion
  • Method Details

    • run

      public abstract void run()
      Executes the worker’s task on this thread.

      Implementations may use up to poolSize parallel subworkers. On successful completion, they should invoke signalDone.

      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • getResult

      public abstract Object getResult()
      Returns the aggregated result produced by this worker.

      Behavior is undefined if invoked before the thread has completed successfully. Callers must ensure successful completion before calling this method.

      Returns:
      the result object