Probably this is a silly question but I couldn’t find any solution for that.
I want to iterate over a vector of my own type and do some calculation.
Here is a MWE
# julia -p 5
@everywhere mutable struct MyType
val::Int64
end
function check_move(v::Vector{MyType})
@sync @distributed for i in 1:length(v)
# for i in 1:length(v)
sleep(1)
v[i].val = 100
end
end
# initialize the vector of my own type
my_vec = Vector{MyType}(undef,5)
for i in 1:5
my_vec[i] = MyType(i)
end
# try to change each one of the values to 100
@time check_move(my_vec)
julia> my_vec
# 5-element Vector{MyType}:
# MyType(1)
# MyType(2)
# MyType(3)
# MyType(4)
# MyType(5)
But it should be a vector with MyType(100), why does this happen?
Thanks,
Elyco