RosettaCodeData/Task/Distributed-programming/Julia/distributed-programming-2.julia
2019-09-12 10:33:56 -07:00

7 lines
330 B
Text

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