Class WorkerThread

java.lang.Object
java.lang.Thread
nl.tudelft.simulation.language.concurrent.WorkerThread
All Implemented Interfaces:
Runnable

public class WorkerThread extends Thread
The WorkerThread is a working thread. The thread sleeps while not interrupted. If interrupted the job.run operation is invoked.

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Author:
Peter H.M. Jacobs, Alexander Verbraeck
  • Constructor Details

    • WorkerThread

      public WorkerThread(String name, Runnable job)
      constructs a new SimulatorRunThread.
      Parameters:
      name - String; the name of the thread
      job - Runnable; the job to run
  • Method Details

    • cleanUp

      public void cleanUp()
      Clean up the worker thread. synchronized method, otherwise it does not own the Monitor on the wait.
    • isRunning

      public boolean isRunning()
      Returns:
      whether the run method of the job is running or not
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread