Separating the launching of tasks and the processing of their results in an executor
Normally, when you execute concurrent tasks using an executor, you will send
Callable tasks to the executor and get
Future objects to control the method. You can find situations, where you need to send the tasks to the executor in one object and process the results in another one. For such situations, the Java Concurrency API provides the
CompletionService class has a method to send the tasks to an executor and a method to get the
Future object for the next task that has finished its execution. Internally, it uses an
Executor object to execute the tasks. This behavior has the advantage to share a
CompletionService object, ...