If you look for built-in solution, only @distributed has support for parallel reductions (multiprocessing). If my memory doesn’t fail me, it was named @parallel a (very) long time ago (it doesn’t fail me). If you want a multithreading solution, you would have to write it yourself or you could use, e.g., OhMyThreads.jl
using OhMyThreads
function pflip_coin(times)
count = @tasks for i in 1:times
@set reducer=+
Int(rand(Bool))
end
end
# or, equivalently
function pflip_coin(times)
count = treduce(+, 1:times) do i
Int(rand(Bool))
end
end