I think I’ve found an example that explain things fabulously
julia> function main()
work = function(x)
sleep(60)
println(x)
end
v = [3, 4, 5]
for ȷ = 1:2 Threads.@spawn work( $(v[ȷ]) ) end
work, v = function(x)
sleep(0.7)
println(10x)
end, -v
end;
julia>
julia> main();
julia> 40
30
If the $()
were removed, then v
is volatile as work
is.
Edit: we can also write Threads.@spawn $work($v[ȷ])