Class WorkerPool


public final class WorkerPool extends SystemLogger
This class helps you create a worker pool.
  • Constructor Details

    • WorkerPool

      public WorkerPool(String name, int noOfThreads, int maxNoOfTasks)
      Create a new worker pool.
      Parameters:
      name - the worker pool's name
      noOfThreads - number of provided threads
      maxNoOfTasks - the maximum supported tasks
  • Method Details

    • execute

      public void execute(Runnable task, String debugText) throws IllegalStateException
      Executes a task.
      Parameters:
      task - a runnable to do a particular job
      debugText - a supported text using for debugging or logging
      Throws:
      IllegalStateException - when you try to execute an unstopped task
    • stop

      public void stop()
      Stop a task.
    • waitUntilAllTasksFinished

      public void waitUntilAllTasksFinished()
      Wait until all tasks are finished.