A parallel stream splits its source into parts and processes them on several threads at once, then combines the results. You get one by calling parallelStream() on a collection or parallel() on an existing stream; sequential() switches back, and isParallel() tells you the mode. Because the whole pipeline has a single mode, the last parallel() or sequential() call wins. By default the work runs in the common ForkJoinPool.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 5 more sections, 4 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.