Thread internals and related design patterns
summary
Explains two concrete patterns and two anti‑patterns with Java code: a keyed executor that hashes keys to single‑threaded ExecutorServices to enforce causal ordering (implemented and published on GitHub), and request collapsing where the cache stores a CompletionStage/CompletableFuture to collapse duplicate DB queries — this reduces duplicate IO and releases multiple waiters when one DB call completes. Warns that naive futures cause an execution rabbit hole and recommends CompletableFuture chaining and thenApplyAsync; notes risks (thread thrashing, complex exception handling) and tradeoffs in latency vs throughput.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 6:51causal ordering
- 13:53keyed executor
- 18:10request collapsing
- 27:08antipattern
- 28:15general idea
- 35:26callbacks
- 43:44future everywhere
related talks
28mBack to the CompletableFuture: Concurrency
50mFlavors of Concurrency in Java
47mA Deeper Dive into Java Concurrency Updates
01h 01mMultithreading vs Asynchronous Programming: The Architectural Shift
56mFlavors of Concurrency in Java
47m“Multithreading is the answer. What is the question? (part 1 of 2)”
41mStructured Concurrency in Java: The What & Why
50mThe Hidden Art of Thread-Safe Programming: Exploring java.util.con...
