I think (without looking) it is because enumerating over Dicts uses an Iterator with internal state which is not threadsafe
This works
Threads.@threads for (w,i) in collect(wds_dict)
lock(lk) do
push!(df, [w i])
end
end
Although I prefer to just collect the keys
k = collect(keys(wds_dict))
Threads.@threads for i in 1:length(k)
lock(lk) do
push!(df, [k[i] wds_dict[k[i]]])
end
end