Skip to content

Commit 8d62156

Browse files
committed
iluwatar#107 JavaDoc improvements for Async Method Invocation example
1 parent ef6a34e commit 8d62156

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,24 @@
33
import java.util.concurrent.Callable;
44

55
/**
6-
* <p>
76
* This application demonstrates the async method invocation pattern. Key parts of the pattern are
87
* <code>AsyncResult</code> which is an intermediate container for an asynchronously evaluated value,
98
* <code>AsyncCallback</code> which can be provided to be executed on task completion and
109
* <code>AsyncExecutor</code> that manages the execution of the async tasks.
11-
* </p>
1210
* <p>
1311
* The main method shows example flow of async invocations. The main thread starts multiple tasks with
1412
* variable durations and then continues its own work. When the main thread has done it's job it collects
1513
* the results of the async tasks. Two of the tasks are handled with callbacks, meaning the callbacks are
1614
* executed immediately when the tasks complete.
17-
* </p>
1815
* <p>
1916
* Noteworthy difference of thread usage between the async results and callbacks is that the async results
2017
* are collected in the main thread but the callbacks are executed within the worker threads. This should be
2118
* noted when working with thread pools.
22-
* </p>
2319
* <p>
2420
* Java provides its own implementations of async method invocation pattern. FutureTask, CompletableFuture
2521
* and ExecutorService are the real world implementations of this pattern. But due to the nature of parallel
2622
* programming, the implementations are not trivial. This example does not take all possible scenarios into
2723
* account but rather provides a simple version that helps to understand the pattern.
28-
* </p>
2924
*
3025
* @see AsyncResult
3126
* @see AsyncCallback

async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncCallback.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
import java.util.Optional;
44

5+
/**
6+
*
7+
* AsyncCallback interface
8+
*
9+
* @param <T>
10+
*
11+
*/
512
public interface AsyncCallback<T> {
613

714
/**

async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncExecutor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import java.util.concurrent.Callable;
44
import java.util.concurrent.ExecutionException;
55

6+
/**
7+
*
8+
* AsyncExecutor interface
9+
*
10+
*/
611
public interface AsyncExecutor {
712

813
/**

async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncResult.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
import java.util.concurrent.ExecutionException;
44

5+
/**
6+
*
7+
* AsyncResult interface
8+
*
9+
* @param <T>
10+
*/
511
public interface AsyncResult<T> {
612

713
/**

async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import java.util.concurrent.atomic.AtomicInteger;
77

88
/**
9+
*
910
* Implementation of async executor that creates a new thread for every task.
11+
*
1012
*/
1113
public class ThreadAsyncExecutor implements AsyncExecutor {
1214

0 commit comments

Comments
 (0)