Class WorkerThread

java.lang.Object
modelarium.multithreading.WorkerThread
All Implemented Interfaces:
Callable<modelarium.results.Results>

public class WorkerThread extends Object implements 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

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    modelarium.results.Results
    Executes the simulation loop for this worker.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 settings
      requestResponseController - the controller for cross-thread coordination
      environment - the model's environment
      agentsInThread - the agents assigned to this thread
      sharedClock - the clock used to synchronise the entities and cores in the model
      randomGenerator - the splittable random generator this worker and its agents can use
  • Method Details

    • call

      public modelarium.results.Results call() throws InterruptedException
      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:
      call in interface Callable<modelarium.results.Results>
      Returns:
      a Results object containing final agent-level outputs
      Throws:
      InterruptedException