Streams

A stream represents a sequence of elements and can perform a series of operations on them

strings.stream()
.filter(s -> !s.equals(""))
.map(String::toUpperCase)
.sorted()
.forEach(System.out::println);

Operations on streams can be intermediate or final.

These operations must work without interference and stateless.

From the viewpoint of parallelism, an important benefit of using Java streams when possible is that the pipeline can be made to execute in parallel by designating the source to be a parallel stream, by simply replacing .stream() by .parallelStream() or Stream.of(xxx).parallel. This form of functional parallelism is a major convenience for the programmer, since they do not need to worry about explicitly allocating intermediate collections, or about ensuring that parallel accesses to data collections are properly synchronized.