Class Worker

    • Constructor Detail

      • Worker

        public Worker​(java.lang.String name)
        Creates a Worker that will use a shared thread pool to process jobs. Also, threads created using this constructor are not persistent. Use this constructor when you do not have a TaskMonitor that wants updates from this worker.
        Parameters:
        name - the name of the shared thread pool.
      • Worker

        public Worker​(java.lang.String name,
                      TaskMonitor monitor)
        Creates a Worker 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.
      • Worker

        public Worker​(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

      • createGuiWorker

        public static Worker createGuiWorker()
        A convenience method to create a Worker that uses a shared thread pool for performing operations for GUI clients in a background thread

        Note: the shared thread pool of the worker created here has a max number of threads as defined by SystemUtilities.getDefaultThreadPoolSize(). If there is a point in time where we notice contention in thread due to too many clients of this method (i.e., too many tasks are blocking because the thread pool is full), then we can update the size of the thread pool for this Worker.

        Returns:
        the new worker