Module de.seggebaeing.sqlanalyzer
Class WorkerThread
java.lang.Object
java.lang.Thread
de.seggebaeing.sqlanalyzer.logic.util.thread.WorkerThread
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
EvaluationThread
,GenerationThread
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionWorkerThread
(String name, int poolSize, Runnable signalDone) Constructs aWorkerThread
with a name, a maximum subworker pool size, and an optional completion callback. -
Method Summary
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
signalDone
-
poolSize
protected final int poolSize
-
-
Constructor Details
-
WorkerThread
Constructs aWorkerThread
with a name, a maximum subworker pool size, and an optional completion callback.- Parameters:
name
- the thread namepoolSize
- number of parallel subworkers to usesignalDone
- 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 invokesignalDone
. -
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
-