0 votes
in Education by (54.6k points)

What is Parallel Processing in Java 8?

1 Answer

0 votes
by (54.6k points)

What is Parallel Processing in Java 8?

parallelStream is the alternative of stream for parallel processing. Take a look at the following code segment that prints a count of empty strings using parallelStream.

List<String> strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");

//get count of empty string

int count = strings.parallelStream().filter(string -> string.isEmpty()).count();

//It is very easy to switch between sequential and parallel streams.

...