Package ghidra.util.worker

# Class Worker

java.lang.Object
ghidra.util.worker.AbstractWorker<Job>
ghidra.util.worker.Worker

public class Worker extends AbstractWorker<Job>
Executes a single job at a time in FIFO order.

See Also:
  - `PriorityWorker`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Worker(String name)`
  Creates a Worker that will use a shared thread pool to process jobs.
  `Worker(String name, boolean isPersistentThread, boolean useSharedThreadPool, TaskMonitor monitor)`
  This constructor allows you to change persistence and shared thread pool usage.
  `Worker(String name, TaskMonitor monitor)`
  Creates a Worker that will use a shared thread pool to process jobs.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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

  ### Methods inherited from class ghidra.util.worker.AbstractWorker

  `clearAllJobs, clearAllJobsWithInterrupt_IKnowTheRisks, clearPendingJobs, dispose, isBusy, isDisposed, schedule, setBusyListener, setTaskMonitor, waitUntilNoJobsScheduled`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Worker

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

  - ### 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