Class AbstractWorker

Direct Known Subclasses:
AbstractCycleWorker, AbstractImmediateWorker, AppInstallWorker, AppSynchronizeWorker, AppValidateWorker, ClientReconnectorWorker, ComponentManagerWorker, CycleWorker, DiskSpaceWorker, NetworkConfigurationWorker, ReadWorker, UsbConfigurationWorker

public abstract class AbstractWorker extends Object
Defines a generic Worker Thread.

The business logic of the Worker is inside the forever() method. It is executed by default every getCycleTime() seconds. Additionally execution can be triggered by calling the triggerNextRun() method.

If Cycle-Time is negative (e.g. by using ALWAYS_WAIT_FOR_TRIGGER_NEXT_RUN) the forever() method is called only after triggering it.

If Cycle-Time is zero (e.g. by using DO_NOT_WAIT), the forever() method is always called immediately without any delay.

  • Field Details


      public static final int ALWAYS_WAIT_FOR_TRIGGER_NEXT_RUN
      See Also:

      public static final int DO_NOT_WAIT
      See Also:
    • thread

      protected final Thread thread
  • Constructor Details

    • AbstractWorker

      public AbstractWorker()
  • Method Details

    • activate

      public void activate(String name)
      Initializes the worker and starts the worker thread.
      name - the name of the worker thread
    • modified

      public void modified(String name)
      Modifies the worker thread.
      name - the name of the worker thread
    • deactivate

      public void deactivate()
      Stops the worker thread.
    • forever

      protected abstract void forever() throws Throwable
      This method is called in a loop forever until the Thread gets interrupted.
    • getCycleTime

      protected abstract int getCycleTime()
      Gets the cycleTime of this worker in [ms].
      • > 0 sets the minimum execution time of one Cycle
      • = 0 never wait between two consecutive executions of forever()
      • < 0 causes the Cycle to sleep forever until 'triggerNextRun()' is called
      the cycleTime
    • triggerNextRun

      public void triggerNextRun()
      Allows the next execution of the forever() method.