2

I wonder, is it thread-safe to use pre-defined collectors (like Collectors.toSet, Collectors.toList) on parallel streams, which are created using collection.parallelStream() method?

Or one has to use custom synchronized collector, like this?

collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>())))
Tunaki
  • 125,519
  • 44
  • 317
  • 399
voho
  • 2,567
  • 1
  • 19
  • 26
  • you are right, but the question was title so specific i could not find it - will try to edit the original – voho Nov 12 '15 at 10:25

0 Answers0