# Number of threads, puzzle

**URL:** <https://discourse.julialang.org/t/number-of-threads-puzzle/74965>\
**Category:** General Usage\
**Tags:** question, task, threads\
**Created:** [January 21, 2022, 2:47am UTC](https://discourse.julialang.org/t/number-of-threads-puzzle/74965 "2022-01-21T02:47:50Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [January 21, 2022, 8:24am UTC](https://discourse.julialang.org/t/number-of-threads-puzzle/74965/4 "2022-01-21T08:24:45Z")

</div>

Well it’s not just the “Julia threads” that get started. There’s also (at least) a signal thread (see `signals-unix.c`) as well as multiple OpenBLAS threads (`libopenblas64_.so`).

I’d suggest to do the following. First, use the built-in `Threads.nthreads()` to see that the number of Julia threads matches your expectation. Second, set `OPENBLAS_NUM_THREADS=1` and rerun your original experiment to exclude the effect of OpenBLAS threads. Third, you may want something like done [here](https://discourse.julialang.org/t/thread-affinitization-pinning-julia-threads-to-cores/58069/7) and use `gdb` with a breakpoint at `pthread_create` to see which threads get started on a more fundamental level. Hope that helps.

**UPDATE:**

I just ran a simple experiment myself (with `OPENBLAS_NUM_THREADS=1`). I find

```julia
julia -t 1 # 2 threads
julia -t 2 # 3 threads
julia -t 3 # 4 threads
...

```

where I checked the number of threads with `htop`.

---

_[View the full topic](https://discourse.julialang.org/t/number-of-threads-puzzle/74965)._
