# Number of threads available seems random (using @spawn)

**URL:** <https://discourse.julialang.org/t/number-of-threads-available-seems-random-using-spawn/44594>\
**Category:** New to Julia\
**Tags:** parallel\
**Created:** [August 9, 2020, 12:03am UTC](https://discourse.julialang.org/t/number-of-threads-available-seems-random-using-spawn/44594 "2020-08-09T00:03:22Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [August 9, 2020, 3:34pm UTC](https://discourse.julialang.org/t/number-of-threads-available-seems-random-using-spawn/44594/6 "2020-08-09T15:34:44Z")

</div>

I had something similar going on in my recent attempts to parallelize Agents.jl models [[solved] Agents.jl spending ¾ of its time doing something before it even starts to compute?](https://discourse.julialang.org/t/solved-agents-jl-spending-3-4-of-its-time-doing-something-before-it-even-starts-to-compute/44109)

yes the initial question was about profiling, but in the end I was seeing failure to spread the load across available threads.

one thing I discovered was that @spawn tasks do not migrate across threads yet, so if you get unlucky and have two tasks on one thread, they serialize.

actually more related post: [Threading usage patterns: Worker pools for Agents.jl and SQLite.jl](https://discourse.julialang.org/t/threading-usage-patterns-worker-pools-for-agents-jl-and-sqlite-jl/44232)

---

_[View the full topic](https://discourse.julialang.org/t/number-of-threads-available-seems-random-using-spawn/44594)._
