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
  • 132,869
  • 46
  • 340
  • 423
voho
  • 2,805
  • 1
  • 21
  • 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