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<>())))