ExecutorCompletionService

Class Overview

A CompletionService that uses a supplied Executor
to execute tasks. This class arranges that submitted tasks are,
upon completion, placed on a queue accessible using take.
The class is lightweight enough to be suitable for transient use
when processing groups of tasks.

Usage Examples.
Suppose you have a set of solvers for a certain problem, each
returning a value of some type Result, and would like to
run them concurrently, processing the results of each of them that
return a non-null value, in some method use(Result r). You
could write this as:

Parameters

Throws

Creates an ExecutorCompletionService using the supplied
executor for base task execution and the supplied queue as its
completion queue.

Parameters

executor

the executor to use

completionQueue

the queue to use as the completion queue
normally one dedicated for use by this service. This
queue is treated as unbounded -- failed attempted
Queue.add operations for completed taskes cause
them not to be retrievable.