Parallelism
Jump to navigation
Jump to search
External
Internal
Overview
Parallelism can be exploited when the code that is executed in parallel is safe, meaning the code does not access shared data. This code is referred to as pure function.
Streams API and Parallelism
The Streams API exposes map and reduce operations, which then can be internally parallelized over the elements of the stream, provided that the functions that are used in mapping and reductions are associative, stateless and non-interfering. Map-reduce is an alternative to iterative operations, which involves sharing state and does not parallelize gracefully.
Parallelizing computation requires partitioning the input, applying transformations, then reducing the results.