Class PriorityWorker

    • Constructor Detail

      • PriorityWorker

        public PriorityWorker​(java.lang.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​(java.lang.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 Detail

      • schedule

        public void schedule​(PriorityJob job)
        Description copied from class: AbstractWorker
        Schedules the job for execution. Jobs will be processed 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)
        Overrides:
        schedule in class AbstractWorker<PriorityJob>
        Parameters:
        job - the job to be executed.