# Threading: Array comprehension vs. fill

**URL:** <https://discourse.julialang.org/t/threading-array-comprehension-vs-fill/42604>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 6, 2020, 11:54am UTC](https://discourse.julialang.org/t/threading-array-comprehension-vs-fill/42604 "2020-07-06T11:54:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [July 6, 2020, 12:00pm UTC](https://discourse.julialang.org/t/threading-array-comprehension-vs-fill/42604/2 "2020-07-06T12:00:08Z")

</div>

I think the issue is that `fill` gets one array & re-uses it, see e.g. here: [Structure Usage - #2 by mcabbott](https://discourse.julialang.org/t/structure-usage/42269/2) . And I guess that in `mwe_fill(N)` the different threads are over-writing each other’s results.

Edit – actually, no overwriting is necessary, you get the same result without threads. `mwe_comprehension(4)` simply contains `sum(1:4)`, while `mwe_fill(4)` contains that times the number of threads.

But the result of `mwe_fill` is not safe, e.g. `unique(mwe_fill(100))` has a variety of numbers, different on every run.

---

_[View the full topic](https://discourse.julialang.org/t/threading-array-comprehension-vs-fill/42604)._
