Idiom # 30: Parallelize execution of 1000 independent tasks
See programming-idioms.org :
Code
Thread Concurrency in Fuzion is provided though the
effect concur.thread. This effect provides an
operation spawn that computes a function in parallel.
Runnable Example
Code input
ex30 is
f(i i32) =>
say "**$i**"
for i in 1..1000 do
_ := concur.threads.spawn (() -> f i)
time.nano.sleep (time.duration.s 2)
Alternatively, we can use map:
Code input
ex30 is
f(i i32) =>
say "**$i**"
(1..1000).map (i-> concur.threads.spawn (() -> f i))
.for_each x->unit
time.nano.sleep (time.duration.s 2)
last changed: 2026-02-20