org.snmp4j.util
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
 void cancel()
          Cancels all threads non-blocking by interrupting them.
 void execute(WorkerTask task)
          Executes a task on behalf of this worker pool.
 boolean isIdle()
          Checks if all workers of the pool are idle.
 void stop()
          Stops all threads in this worker pool gracefully.
 boolean tryToExecute(WorkerTask task)
          Tries to execute a task on behalf of this worker pool.
 

Method Detail

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.

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.