The Gatherer API: the tool that was missing in the Stream API
summary
JDK 24 adds the Gatherer API to model intermediate Stream operations with a concrete gather(stream) → stream primitive. It exposes an initializer, integrator, combiner, finisher lifecycle, integrators can be greedy or non‑greedy, and downstream.push returns a boolean that implements backpressure. Parallel execution creates one mutable state per thread and uses the combiner; ready gatherers include window, scan, fold and mapConcurrent (mapping on virtual threads). Watch for closing sources and thread‑safety when mutating external state.
AI-written summary · about
chapters (6)
- 0:00Introduction and Java versions
- 10:57Stream API limitations
- 23:02Gatherer API basics
- 35:32State and finisher in gatherers
- 43:38Parallel gatherers and combiners
- 50:31Summary and Q&A
related talks
43mStream Gatherers - Deep Dive with the Expert
40mStream Gathers - The biggest change to Java Streams since 10 years
48mWe Are All Gathered — We Are All to Gather
45mStream Gatherers
44mLevel Up Your Java Streams with Gatherers
46mJEP 461: Breathing New Life into Java Stream API
45mHunting with Stream Gatherers
51mHunting with Stream Gatherers
