Section 23.14 (Advanced) Interfaces Callable and Future
• The Callable
(p. 1030) interface (of package java.util.concurrent
) declares a single method named call
that allows a task to return a value.
• ExecutorService
method submit
(p. 1030) executes a Callable
passed in as its argument. Method submit
returns an object of type Future
(of package java.util.concurrent
) that represents the future result of the executing Callable
.
• Interface Future
(p. 1030) declares method get
to return the result of the Callable
. The interface also provides methods that enable you to cancel a Callable
’s execution, determine whether the Callable
was cancelled and determine whether the Callable
completed its task.
• Java SE 8 introduces a new CompletableFuture ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.