parallel stream
A stream that splits its work across several threads from the common pool, which can speed up large computations and slow down small ones.
In more detail
Splitting, coordinating and combining results all cost time, so a small list is often faster sequentially. Callbacks must be safe to run concurrently, and blocking calls to databases or remote services do not belong there. Measure before choosing parallel; sequential is the right default for request code.
Related terms
- Stream API — The standard-library toolkit for describing a sequence of data-processing steps, such as filter, map and collect, over a source like a list.
- thread — A path of execution inside a process that the operating system schedules on a processor; one process can have many.
- common pool — The JVM-wide shared thread pool that parallel streams and CompletableFuture use by default when you do not supply an executor.
- concurrency — Having several pieces of work in progress during overlapping periods of time, such as requests being handled at once.
Taught in
- Advanced Stream Operations — Modern Java: Virtual Threads & High-Throughput Services
- Reduction, Grouping And Partitioning — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Lambdas And Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Thread Safety: Locks And Atomics — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Concurrent Collections And Parallel Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Modules And Concurrency — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep