Parallelism: Difference between revisions
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
=Streams API and Parallelism= | =Streams API and Parallelism= | ||
The Streams API exposes [[Transforming Data with Java 8 Streams API#Overview|map]] and [[Java_8_Streams_API#Reduction|reduce]] operations, which then can be internally parallelized over the elements of the stream. | The Streams API exposes [[Transforming Data with Java 8 Streams API#Overview|map]] and [[Java_8_Streams_API#Reduction|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 [[Functional_Programming#Associative_Function|associative]], [[Functional_Programming#Stateless_Function|stateless]] and [[Functional_Programming#Non-Interfering_Function|non-interfering]]. |
Revision as of 02:15, 29 March 2018
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.