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 + * + */ public interface AsyncCallback { /** diff --git a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncExecutor.java b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncExecutor.java index 4bf837a4f..5c5098487 100644 --- a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncExecutor.java +++ b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncExecutor.java @@ -3,6 +3,11 @@ package com.iluwatar.async.method.invocation; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; +/** + * + * AsyncExecutor interface + * + */ public interface AsyncExecutor { /** diff --git a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncResult.java b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncResult.java index 689095e9d..405bec251 100644 --- a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncResult.java +++ b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncResult.java @@ -2,6 +2,12 @@ package com.iluwatar.async.method.invocation; import java.util.concurrent.ExecutionException; +/** + * + * AsyncResult interface + * + * @param + */ public interface AsyncResult { /** diff --git a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutor.java b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutor.java index 18b27c3b6..a3ed51af3 100644 --- a/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutor.java +++ b/async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutor.java @@ -6,7 +6,9 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; /** + * * Implementation of async executor that creates a new thread for every task. + * */ public class ThreadAsyncExecutor implements AsyncExecutor {