diff --git a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java index de4dfe926..688d8482f 100644 --- a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java +++ b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java @@ -3,29 +3,24 @@ package com.iluwatar.async.method.invocation; import java.util.concurrent.Callable; /** - *
* This application demonstrates the async method invocation pattern. Key parts of the pattern are
* AsyncResult
which is an intermediate container for an asynchronously evaluated value,
* AsyncCallback
which can be provided to be executed on task completion and
* AsyncExecutor
that manages the execution of the async tasks.
- *
* The main method shows example flow of async invocations. The main thread starts multiple tasks with * variable durations and then continues its own work. When the main thread has done it's job it collects * the results of the async tasks. Two of the tasks are handled with callbacks, meaning the callbacks are * executed immediately when the tasks complete. - *
** Noteworthy difference of thread usage between the async results and callbacks is that the async results * are collected in the main thread but the callbacks are executed within the worker threads. This should be * noted when working with thread pools. - *
** Java provides its own implementations of async method invocation pattern. FutureTask, CompletableFuture * and ExecutorService are the real world implementations of this pattern. But due to the nature of parallel * programming, the implementations are not trivial. This example does not take all possible scenarios into * account but rather provides a simple version that helps to understand the pattern. - *
* * @see AsyncResult * @see AsyncCallback diff --git a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java index 067b79d43..46556a48e 100644 --- a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java +++ b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java @@ -2,6 +2,13 @@ package com.iluwatar.async.method.invocation; import java.util.Optional; +/** + * + * AsyncCallback interface + * + * @param