# Issue number of threads

**URL:** <https://discourse.julialang.org/t/issue-number-of-threads/14593>\
**Category:** New to Julia\
**Created:** [September 5, 2018, 6:01pm UTC](https://discourse.julialang.org/t/issue-number-of-threads/14593 "2018-09-05T18:01:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![OlivierHnt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olivierhnt/32/6227_2.png) [@OlivierHnt](https://discourse.julialang.org/u/OlivierHnt)\
**Post date:** [September 5, 2018, 6:01pm UTC](https://discourse.julialang.org/t/issue-number-of-threads/14593/1 "2018-09-05T18:01:36Z")

</div>

Hello, I was recently suggested to try the multi-threading functionality, but I have not been successful.

In the terminal I run `export JULIA_NUM_THREADS=4` (which I know I have by running `sysctl hw.ncpu`). In the REPL I call `Threads.nthreads()` but the output remains 1.

What step am I missing ?

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [September 5, 2018, 6:07pm UTC](https://discourse.julialang.org/t/issue-number-of-threads/14593/2 "2018-09-05T18:07:13Z")

</div>

Did you set the environment variable before starting Julia? What is `ENV["JULIA_NUM_THREADS"]`?

---

<div class="post-metadata">

**Author:** ![OlivierHnt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olivierhnt/32/6227_2.png) [@OlivierHnt](https://discourse.julialang.org/u/OlivierHnt)\
**Post date:** [September 5, 2018, 6:18pm UTC](https://discourse.julialang.org/t/issue-number-of-threads/14593/3 "2018-09-05T18:18:05Z")

</div>

As a matter of fact I did not, when running your command I get ERROR: KeyError: key “JULIA\_NUM\_THREADS” not found.

I simply followed [https://docs.julialang.org/en/v1/manual/parallel-computing/#Multi-Threading-(Experimental)-1](https://docs.julialang.org/en/v1/manual/parallel-computing/#Multi-Threading-(Experimental)-1).

How do I set the environment ? Are the steps in the Documentation as well ?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [September 5, 2018, 6:19pm UTC](https://discourse.julialang.org/t/issue-number-of-threads/14593/4 "2018-09-05T18:19:49Z")

</div>

What you did should work, but you probably need to start julia from the same terminal as you set the variable.

---

<div class="post-metadata">

**Author:** ![OlivierHnt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olivierhnt/32/6227_2.png) [@OlivierHnt](https://discourse.julialang.org/u/OlivierHnt)\
**Post date:** [September 5, 2018, 6:21pm UTC](https://discourse.julialang.org/t/issue-number-of-threads/14593/5 "2018-09-05T18:21:22Z")

</div>

Indeed, that was it… I did not know changing terminal windows could affect anything. Thank you very much.
