Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wang Mo: Elaborate on allOf() in AsyncIntro.md #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contents/textbook/lecture11/asyncIntro/asyncIntro.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ Suppose you have several `CompletableFuture` objects, say `cf1`, `cf2`, and `cf3
CompletableFuture.allOf(cf1, cf2, cf3).join();
```

The object created by `CompletableFuture.allOf(cf1, cf2, cf3)` completes, only after all of `cf1`, `cf2`, `cf3` completes.
The object created by `CompletableFuture.allOf(cf1, cf2, cf3)` completes, only after all of `cf1`, `cf2`, `cf3` completes. We need to take note that when call `join()` after `allOf()`, the result when completing `cf1`, `cf2`, and `cf3` individually would not be returned, since it is hard to determine the return type considering all different possibilities of the types of the value these objects may return. If we want to return the values of each object, we need to call `join()` for each of them individually.

There is also a `anyOf`, for cases where it is sufficient for any one of the `CompletableFuture` to complete:
```Java
CompletableFuture.anyOf(cf1, cf2, cf3).join();
```

To learn more, [click here](asyncIntro2.html)
To learn more, [click here](asyncIntro2.html)