# Enumerate with keys from a dict

**URL:** <https://discourse.julialang.org/t/enumerate-with-keys-from-a-dict/42413>\
**Category:** New to Julia\
**Created:** [July 2, 2020, 7:33am UTC](https://discourse.julialang.org/t/enumerate-with-keys-from-a-dict/42413 "2020-07-02T07:33:21Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [July 2, 2020, 8:04am UTC](https://discourse.julialang.org/t/enumerate-with-keys-from-a-dict/42413/4 "2020-07-02T08:04:36Z")

</div>

The problem here is that `Dict` is not thread safe and you are therefore creating race conditions. You might be interested in this thread:

> [@Can dicts be threadsafe?](https://discourse.julialang.org/t/can-dicts-be-threadsafe/27172):
>
> dict = Dict{Int64,Vector{Float64}}() nentries = 5e5 Threads.@threads for n in 1:nentries dict[n] = [rand() for i in 1:100] end @assert length(dict) == nentries The assertion fails for me in Julia 1.1.0, as the dict is shorter than the number of entries. Is there a way to safely use dicts with threads?

---

_[View the full topic](https://discourse.julialang.org/t/enumerate-with-keys-from-a-dict/42413)._
