Using @distributed for loop

This is purely an issue because you used global scope. This also works:

julia> function foo()
       m = 0
       Threads.@threads for i in 1:1029092090
           m = test(0.0)
           println(m)
       end
       return m
       end