Been looking into Implicit and Explicit concurrency within the Java language and after a fair bit of research wanted to clear a few things up.
Thanks
Implicit parallelism refers to the ability of the compiler to perform certain operation in parallel without "any" hint from the programmer. This is achievable if the computation you want to perform has certain properties (e.g. no data dependencies among the parallel jobs).
Java stream are (quoting Oracle's doc) A sequence of elements supporting sequential and parallel aggregate operations and are fundamentally different to collections because
1) Collections were designed to be fast in accessing and manipulated collection's elements
2) Streams are not meant to be modified, but to create a sort of pipe between source elements and result elements. Result elements are created applying an operation (usually described in functional/lambda-style) to the source. This kind of computation can be safely divided into sub pipes and processed in a parallel way.
Function that make up this pipe have to have the following properties: 1) must be non-interfering (they do not modify the stream source); 2) be stateless (their result should not depend on any state that might change during execution of the stream pipeline). see here
Explicit parallelism (as the name suggest) is achieved by the programmer that can spawn as much (the computing elements) as he needs.Those elements are usually threads or processes (see here for the difference Those computing elements execute concurrently and is up to the programmer to orchestrate all the operations in order to produce the right result (e.g. explicitly synchronize threads, exchanging messages, make transactional operations etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With