# Java 8 Parallel Operations Are Not As Simple As They Seem

DevFeed: [Java 8 Parallel Operations Are Not As Simple As They Seem](<https://devfeed.tech/articles/java-8-parallel-operations-are-not-as-simple-as-they-seem-32213.md>)

Original publisher: [Read original article](<https://bruceeckel.com/2016/04/27/java-8-parallel-operations-are-not-as-simple-as-they-seem/>)

Author: Bruce Eckel

Published: 2016-04-27T00:00:00Z

Content type: article

Language: en

Sources: [Bruce Eckel - Computing Thoughts](<https://devfeed.tech/sources/bruce-eckel-computing-thoughts.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [Streams](<https://devfeed.tech/topics/streams.md>), [Code](<https://devfeed.tech/topics/code.md>), [Algorithms, Complexity](<https://devfeed.tech/topics/algorithms-complexity.md>)

Tags: [algorithms](<https://devfeed.tech/tags/algorithms.md>), [java](<https://devfeed.tech/tags/java.md>), [java-8](<https://devfeed.tech/tags/java-8.md>), [jvm](<https://devfeed.tech/tags/jvm.md>), [parallel](<https://devfeed.tech/tags/parallel.md>), [streams](<https://devfeed.tech/tags/streams.md>)

## AI overview

This article explores Java 8 streams and parallel streams by comparing multiple ways to sum an incremental sequence of numbers. It reports that parallelization can be slower than sequential execution and may run out of memory in some generator-based cases, while noting that timing results are machine-dependent and imperfect.

## Source excerpt

As an exploration of the uncertainties of streams and parallel streams, let's look at a problem that seems simple: summing an incremental sequence of numbers. There turns out to be a surprising number of ways to do this, and I'll take the risk of comparing them through timing--trying to be careful, but acknowledging that I might fall into one of the many fundamental pitfalls when timing code execution. The results may have some flaws (there's no "warming up" of the JVM, for example), but I think it nonetheless gives some useful indications.