Skip to content

Commit b66dc5e

Browse files
committed
sample updated
1 parent bcd0533 commit b66dc5e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/test/java/net/tascalate/concurrent/J8Examples.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,23 @@ public static void main(final String[] argv) throws InterruptedException, Execut
8585
System.out.println(e);
8686
});
8787
*/
88-
Thread.sleep(10000);
8988
//timeout.cancel(true);
90-
//System.exit(0);
91-
9289

9390
Promises.all(IntStream.range(1, 5)
9491
.mapToObj(i -> CompletableTask.supplyAsync(() -> awaitAndProduce1(i, 100), executorService))
9592
.collect(Collectors.toList())
9693
)
94+
.thenApply(v -> {System.out.println("PARTITIONED SOURCE: " + v); return v;})
9795
.thenApply(Collection::stream)
9896
.as(partitionedStream(2, i -> CompletableTask.supplyAsync(() -> awaitAndProduce1(i, 1000), executorService), Collectors.toList()))
9997
.whenComplete((r, e) -> {
10098
System.out.println("PARTITIONED: " + r + " ON " + Thread.currentThread());
10199
//System.exit(0);
102100
});
101+
102+
103+
//Thread.sleep(10000);
104+
//System.exit(0);
103105

104106
IntFunction<Promise<Integer>> makeNewValue = v -> CompletableTask.supplyAsync(() -> awaitAndProduce2(v), executorService);
105107
// MUST be Promises.streamCompletions(..., false) -- while the original stream is generator-base rather than collection based
@@ -291,7 +293,7 @@ private static int multByX(int v) {
291293

292294
private static int awaitAndProduce1(int i, long delay) {
293295
try {
294-
System.out.println("Delay I in " + Thread.currentThread());
296+
System.out.println("Delay I in " + Thread.currentThread() + " >> VAL " + i) ;
295297
Thread.sleep(delay);
296298
if (i < 0) {
297299
throw new RuntimeException("Negative value: " + i);

0 commit comments

Comments
 (0)