Class PriorityWorker


public class PriorityWorker extends AbstractWorker<PriorityJob>
Executes a single job at a time in priority order.

The highest priority jobs are those with the lowest value return by the job's getPriority() method. (i.e. the job with priority 0 will be processed before the job with priority 1)

See Also:
  • Constructor Details

    • PriorityWorker

      public PriorityWorker(String name, TaskMonitor monitor)
      Creates a PriorityWorker that will use a shared thread pool to process jobs. Also, threads created using this constructor are not persistent.
      Parameters:
      name - the name of the shared thread pool.
      monitor - the monitor used to cancel jobs.
    • PriorityWorker

      public PriorityWorker(String name, boolean isPersistentThread, boolean useSharedThreadPool, TaskMonitor monitor)
      This constructor allows you to change persistence and shared thread pool usage.
      Parameters:
      name - the name of the shared thread pool.
      isPersistentThread - if true, the worker thread will stay around when idle; false means that the thread will go away if not needed. Should be true for high frequency usage.
      useSharedThreadPool - true signals to use the given name to find/create a thread pool that can be shared throughout the system.
      monitor - the monitor used to cancel jobs.
  • Method Details

    • schedule

      public void schedule(PriorityJob job)
      Description copied from class: AbstractWorker
      Schedules the job for execution. Jobs will be processed according to the queue supplied at construction time (e.g., in priority order or 1 at a time).
      Overrides:
      schedule in class AbstractWorker<PriorityJob>
      Parameters:
      job - the job to be executed.