Skip to content

Commit 45d4e5d

Browse files
author
Bruce Eckel
committed
touch-ups
1 parent 8268b57 commit 45d4e5d

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

concurrent/Batter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ static <T> T prepare(T ingredient) {
1414
new Nap(100);
1515
return ingredient;
1616
}
17-
static <T> CompletableFuture<T> cf(T ingredient) {
17+
static <T> CompletableFuture<T> prep(T ingredient) {
1818
return CompletableFuture
1919
.completedFuture(ingredient)
20-
.thenApply(Batter::prepare);
20+
.thenApplyAsync(Batter::prepare);
2121
}
2222
public static CompletableFuture<Batter> mix() {
23-
CompletableFuture<Eggs> eggs = cf(new Eggs());
24-
CompletableFuture<Milk> milk = cf(new Milk());
25-
CompletableFuture<Sugar> sugar = cf(new Sugar());
26-
CompletableFuture<Flour> flour = cf(new Flour());
23+
CompletableFuture<Eggs> eggs = prep(new Eggs());
24+
CompletableFuture<Milk> milk = prep(new Milk());
25+
CompletableFuture<Sugar> sugar = prep(new Sugar());
26+
CompletableFuture<Flour> flour = prep(new Flour());
2727
CompletableFuture
2828
.allOf(eggs, milk, sugar, flour)
2929
.join();

concurrent/CatchCompletableExceptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
public class CatchCompletableExceptions {
99
static void handleException(int failcount) {
10-
// Call Function only if there's an exception,
11-
// Must produce same type as came in:
10+
// Call the Function only if there's an
11+
// exception, must produce same type as came in:
1212
CompletableExceptions
1313
.test("exceptionally", failcount)
1414
.exceptionally((ex) -> { // Function

concurrent/CompletedMachina.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
public class CompletedMachina {
88
public static void main(String[] args) {
99
CompletableFuture<Machina> cf =
10-
CompletableFuture.completedFuture(
11-
new Machina(0));
10+
CompletableFuture.completedFuture(
11+
new Machina(0));
1212
try {
1313
Machina m = cf.get(); // Doesn't block
1414
} catch(InterruptedException |

concurrent/FrostedCake.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void main(String[] args) {
2626
.thenCombineAsync(Frosting.make(),
2727
(cake, frosting) ->
2828
new FrostedCake(cake, frosting))
29-
.thenAcceptAsync(System.out::println).join());
30-
// Need to rewrite...
29+
.thenAcceptAsync(System.out::println)
30+
.join());
3131
}
3232
}

0 commit comments

Comments
 (0)