ExecutorCompletionService in practice
This is whereExecutorCompletionService
steps in. It is a thin wrapper around ExecutorService
that "remembers" all submitted tasks and allows you to wait for the first completed, as opposed to first submitted task. In a way ExecutorCompletionService
keeps a handle to all intermediate Future
objects and once any of them finishes, it's returned. Crucial API method is CompletionService.take()
that blocks and waits for any underlying Future
to complete. Here is the submit step with ExecutorCompletionService
:Read full article from ExecutorCompletionService in practice
No comments:
Post a Comment