forked from Apress/functional-interfaces-in-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAllOf.java
More file actions
28 lines (24 loc) · 871 Bytes
/
AllOf.java
File metadata and controls
28 lines (24 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package chapter13;
import java.util.concurrent.CompletableFuture;
public class AllOf
{
static String color1=null;
static String color2=null;
static String color3=null;
public static void main(String[] args)
{
CompletableFuture<String> cf1
= CompletableFuture.supplyAsync( () -> {
color1 = "RED"; return null;});
CompletableFuture<String> cf2
= CompletableFuture.supplyAsync( () -> {
color2 = "GREEN"; return null;});
CompletableFuture<String> cf3
= CompletableFuture.supplyAsync( () -> {
color3 = "BLUE"; return null;});
CompletableFuture
.allOf(cf1,cf2,cf3) // CompletableFuture<Void>
.join(); // Void
System.out.println(color1 + "," + color2 + "," + color3);
}
}