This interface combines the features of an
ExecutorService with the features of a
BlockingQueue. A producer thread may submit
Callable or Runnable tasks for
asynchronous execution. As each submitted task completes, its result,
in the form of a Future object, becomes available
to be removed from the queue by a consumer thread that calls
poll( ) or take( ).
This generic type declares a type variable
V, which represents the result type of all
tasks on the queue.
public interface CompletionService<V> {
// Public Instance Methods
Future<V> poll( );
Future<V> poll(long timeout, TimeUnit unit) throws InterruptedException;
Future<V> submit(Callable<V> task);
Future<V> submit(Runnable task, V result);
Future<V> take( ) throws InterruptedException;
}