Parallel and Asynchronous Programming with Streams and CompletableFuture
summary
Covers concrete rules and demos for Java 8 parallel streams and CompletableFuture: shows a real timing example (17s → 4s with parallel), warns that adding more threads can make performance worse, explains ordering gotchas and that parallel streams master switch affects the whole pipeline, demonstrates that reduce must use identity (not an arbitrary initial value), reveals the common ForkJoin pool default (common ForkJoin pool = cores-1), and shows async composition patterns (compose vs thenCombine) plus Java 9 timeouts; code examples are available for download.
AI-written summary · about
chapters (14)
- 0:00Start
- 2:31Java Concurrency in Practice
- 3:03The Parallel Streams Library
- 6:36The Collection Pipeline Pattern
- 9:08Collection Pipeline Pattern
- 10:12Dark Days before Java 8
- 13:29Parallelism Is a Master Switch
- 14:10Sequential Execution
- 30:37Reduce Method
- 53:39Output the Pool
- 1:25:32Completable Futures
- 1:34:45Example of Creating a Completable Future
- 1:37:12Supplier Functional Interface
- 1:40:49Threat of Execution
related talks
48mParallel Streams, CompletableFuture, and All That: Concurrency in Java 8
50mThinkAsync in Java8
45mThe Power and Perils of Parallel Streams
46mMake Your CPU Cores Sweat with Parallel Streams
44mThinking in Streams
55mBack to the CompletableFuture: Concurrency in Action
50mFrom Concurrent to Parallel
45mKeynote: Where Promises Fall Short
