Normally, when you execute concurrent tasks using an executor, you will send Runnable or 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.
The CompletionService class has a method to send 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 of sharing a CompletionService object and sending tasks to the executor so others can process the results. The limitation is that the second object can only get the Future objects for those tasks that have finished...