How collectors are used when turning the stream in parallel
I actually tried to answer this question How to skip even lines of a Stream<String> obtained from the Files.lines . So I though this collector wouldn't work well in parallel: private static Collector<String, ?, List<String>> oddLines() { int[] counter = {1}; return Collector.of(ArrayList::new, (l, line) -> { if (counter[0] % 2 == 1) l.add(line); counter[0]++; }, (l1, l2) -> { l1.addAll(l2); return l1; }); } but it works. EDIT: It didn't actually work; I got fooled by the fact that my input set was too small to trigger any parallelism; see discussion in comments . I thought it wouldn't work