Grokking Java Interview Questions
Vote

0% completed

​

Parallel Streams

Replacing stream() with parallelStream() changes one word of a program. Four results of that change are less obvious than the word suggests:

  • The sum of seven order totals stays 32,650 in every run.
  • A reduction that computes (a + b) / 2 can give a different result.
  • A call of forEach() may visit the same seven totals in a different order in each run.
  • A LinkedList of 1,000 elements is first copied completely, by one thread.

Each question below explains one of these points, and the division of the work comes first because the other three depend on it.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content