Package modelarium.multithreading
Class WorkerThread<T extends Results>
java.lang.Object
modelarium.multithreading.WorkerThread<T>
- Type Parameters:
T- the type ofResultsthis worker will return
Represents a single worker thread responsible for simulating one subset of agents
across the configured number of ticks.
Each WorkerThread operates on its own AgentSet, may use a local
WorkerCache for caching, and optionally communicates with a coordinator via
RequestResponseInterface if synchronisation is enabled.
-
Constructor Summary
ConstructorsConstructorDescriptionWorkerThread(String threadName, ModelSettings settings, RequestResponseController requestResponseController, AgentSet agents) Constructs a new worker thread to simulate a subset of agents. -
Method Summary
-
Constructor Details
-
WorkerThread
public WorkerThread(String threadName, ModelSettings settings, RequestResponseController requestResponseController, AgentSet agents) Constructs a new worker thread to simulate a subset of agents.- Parameters:
threadName- the thread's name (typically its numeric ID as a string)settings- the simulation settingsrequestResponseController- the controller for cross-thread coordinationagents- the agents assigned to this thread
-
-
Method Details
-
call
public Results call() throws InterruptedException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessExceptionExecutes the simulation loop for this worker.This includes calling the scheduler each tick, synchronising with the coordinator if needed, and collecting agent results after the simulation ends.
- Specified by:
callin interfaceCallable<T extends Results>- Returns:
- a
Resultsobject containing final agent-level outputs - Throws:
InterruptedExceptionNoSuchMethodExceptionInvocationTargetExceptionInstantiationExceptionIllegalAccessException
-