Package groovy.transform
Annotation Interface Parallel
Runs each iteration of an annotated
for loop in parallel
using the current pool or default executor, with structured completion.
Uses Pool.current() if inside a
ParallelScope.withPool(int, java.util.function.Function<groovy.concurrent.AsyncScope, T>) block, otherwise
falls back to ForkJoinPool.commonPool().
While @Parallel provides a convenient way to parallelise
for loops, using the *Parallel collection methods
(e.g. collectParallel, eachParallel) directly may
offer a better debugging experience, as @Parallel performs
internal variable renaming in its generated code.
A blocking loop body on a fork-join pool needs one spare worker
(withPool(concurrentBlockers + 1)). Pool.virtual()
and Pool.io() run the loop on that pool instead; see
ParallelCollectionExtensions.
- Since:
- 6.0.0
- See Also: