1
JavaAdvanced#memory#gc
A parallel stream splits work across multiple threads using the common ForkJoinPool, useful for CPU-bound work on large datasets. Avoid it for small datasets (overhead outweighs benefit), I/O-bound tasks, or operations with shared mutable state.
long count = IntStream.range(0, 10_000_000).parallel().filter(n -> n % 2 == 0).count(); // beneficial for large CPU-bound computation