RosettaCodeData/Task/Distributed-programming/Julia/distributed-programming-2.julia

8 lines
330 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
using Distributed
@everywhere include_string(Main, $(read("count_heads.jl", String)), "count_heads.jl")
a = @spawn count_heads(100000000) # runs on an available processor
b = @spawn count_heads(100000000) # runs on another available processor
println(fetch(a)+fetch(b)) # total heads of 200 million coin flips, half on each CPU