I am wondering if the behaviour in the picture below is intended? Shouldn’t i
stop at 9999
?
I cannot reproduce:
julia> d = Dict((i=>i for i=1:9999));
julia> for (i,v) in enumerate(keys(d))
if i==10000
@show i
end
end
Can you provide a MWE? (And please use text and not pics as those cannot be copy pasted)
1 Like
Thanks for the fast reply! I guess it might be because I am using Threads.@threads
beforehand.
succeded = Dict{Int,Any}()
Threads.@threads for i = 1:1000
succeded[i] = ["a"]
end
length(keys(succeded)) # returns 806
Does that make sense?
The problem here is that Dict
is not thread safe and you are therefore creating race conditions. You might be interested in this thread:
2 Likes