# Problems using Thread.@thread

**URL:** <https://discourse.julialang.org/t/problems-using-thread-thread/20586>\
**Category:** New to Julia\
**Tags:** multithreading\
**Created:** [February 8, 2019, 3:36pm UTC](https://discourse.julialang.org/t/problems-using-thread-thread/20586 "2019-02-08T15:36:54Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)\
**Post date:** [February 8, 2019, 4:24pm UTC](https://discourse.julialang.org/t/problems-using-thread-thread/20586/6 "2019-02-08T16:24:12Z")

</div>

What’s the point of the variable `a` here? I can barely understand this code. Do you have a single-threaded version that works? Could you post that (or a shorter version of it)?

Also note that `rand()` is not thread safe. See [my recent post and suggested workaround here](https://discourse.julialang.org/t/running-for-loop-in-parallel-and-appending-result-to-vector/20487/16).

---

_[View the full topic](https://discourse.julialang.org/t/problems-using-thread-thread/20586)._
