Java Reference
In-Depth Information
7.2.4. Example: A One-shot Execution Service
If a method needs to process a batch of tasks and does not return until all the tasks are fin-
ished, it can simplify service lifecycle management by using a private
Executor
whose
lifetime is bounded by that method. (The
invokeAll
and
invokeAny
methods can often
be useful in such situations.)
hosts. It creates a private executor and submits a task for each host: it then shuts down the
executor and waits for termination, which occurs when all the mail-checking tasks have com-
pleted.
[4]
Listing 7.18. Producer Thread for
IndexingService
.