← All Exercises

Java Parallel Streams

advancedjava~25min

Background

Parallel streams leverage the ForkJoinPool for automatic parallelization of stream operations.

Problem

Write a Java method that processes a large list of numbers in parallel, filtering and summing squares of even numbers.

Input

A large list of integers.

Output

The sum of squares of even numbers, computed in parallel.

Sample tests

Sample 1

Input: [1,2,3,4,5,6,7,8,9,10]
Expected: 220

Your solution

Learning objective

Learn parallel streams, when to parallelize, and the ForkJoinPool common pool.