I am trying a simple Julia code:
using Distributed
addprocs(1)
@everywhere include("count_heads.jl")
a = @spawn count_heads(100000000)
b = @spawn count_heads(100000000)
fetch(a)+fetch(b)
However the count_heads.jl contains the following function:
function count_heads(n)
c::Int = 0
for i = 1:n
c += rand(Bool)
end
c
end
But the above code was showing the error : On worker 2: UndefVarError: count_heads not defined
Does anyone know how to resolve this error??