Package modelarium.multithreading
Class WorkerThread
java.lang.Object
modelarium.multithreading.WorkerThread
- All Implemented Interfaces:
Callable<modelarium.results.Results>
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
ContextCache for caching, and optionally communicates with a coordinator via
RequestResponseInterface if synchronisation is enabled.
-
Constructor Summary
ConstructorsConstructorDescriptionWorkerThread(String threadName, Config config, modelarium.multithreading.requestresponse.RequestResponseController requestResponseController, Environment environment, AgentSet agentsInThread, modelarium.clock.Clock sharedClock, RandomGenerator randomGenerator) Constructs a new worker thread to simulate a subset of agents. -
Method Summary
Modifier and TypeMethodDescriptionmodelarium.results.Resultscall()Executes the simulation loop for this worker.
-
Constructor Details
-
WorkerThread
public WorkerThread(String threadName, Config config, modelarium.multithreading.requestresponse.RequestResponseController requestResponseController, Environment environment, AgentSet agentsInThread, modelarium.clock.Clock sharedClock, RandomGenerator randomGenerator) Constructs a new worker thread to simulate a subset of agents.- Parameters:
threadName- the thread's name (typically its numeric ID as a string)config- the simulation settingsrequestResponseController- the controller for cross-thread coordinationenvironment- the model's environmentagentsInThread- the agents assigned to this threadsharedClock- the clock used to synchronise the entities and cores in the modelrandomGenerator- the splittable random generator this worker and its agents can use
-
-
Method Details
-
call
Executes 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<modelarium.results.Results>- Returns:
- a
Resultsobject containing final agent-level outputs - Throws:
InterruptedException
-