Module org.snmp4j

Interface WorkerPool

All Known Implementing Classes:
ThreadPool

public interface WorkerPool
The WorkerPool interface models an abstract pool of workers (threads) which can execute WorkerTasks concurrently.
Version:
1.9
Author:
Frank Fock
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cancels all threads non-blocking by interrupting them.
    void
    Executes a task on behalf of this worker pool.
    boolean
    Checks if all workers of the pool are idle.
    void
    Stops all threads in this worker pool gracefully.
    boolean
    Tries to execute a task on behalf of this worker pool.
  • Method Details

    • execute

      void execute(WorkerTask task)
      Executes a task on behalf of this worker pool. If all threads are currently busy, this method call blocks until a worker gets idle again which is when the call returns immediately.
      Parameters:
      task - a Runnable to execute.
    • tryToExecute

      boolean tryToExecute(WorkerTask task)
      Tries to execute a task on behalf of this worker pool. If all threads are currently busy, this method returns false. Otherwise the task is executed in background.
      Parameters:
      task - a Runnable to execute.
      Returns:
      true if the task is executing.
    • stop

      void stop()
      Stops all threads in this worker pool gracefully. This method will not return until all threads have been terminated and joined successfully.
    • cancel

      void cancel()
      Cancels all threads non-blocking by interrupting them.
    • isIdle

      boolean isIdle()
      Checks if all workers of the pool are idle.
      Returns:
      true if all workers are idle.