# Setting \`nthreads()\` using the .julia/config/startup.jl file

**URL:** https://discourse.julialang.org/t/setting-nthreads-using-the-julia-config-startup-jl-file/35427
**Category:** General Usage
**Created:** [March 2, 2020, 8:16pm UTC](https://discourse.julialang.org/t/setting-nthreads-using-the-julia-config-startup-jl-file/35427 "2020-03-02T20:16:49Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [March 3, 2020, 1:48am UTC](https://discourse.julialang.org/t/setting-nthreads-using-the-julia-config-startup-jl-file/35427/22 "2020-03-03T01:48:50Z")

</div>

> [@oliver](#):
>
> How is it different to specify an environment variable in `startup.jl` than from the terminal?

I’m not sure what exactly you are asking here.

1. It’s different because it’s julia code and it can never ever do anything that you cannot do in julia code, this include setting an environment variable to be used before julia starts.
2. The number of thread is fixed on startup, it cannot be changed once julia, as in the runtime, starts running.
3. The startup.jl is not meant to be able to do everything and is not meant to run **before** startup.
4. This is [documented](https://docs.julialang.org/en/v1/manual/environment-variables/#Environment-Variables-1) (See the note).

---

<div class="post-metadata">

### Author: ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)
#### Post date: [March 3, 2020, 4:21am UTC](https://discourse.julialang.org/t/setting-nthreads-using-the-julia-config-startup-jl-file/35427/23 "2020-03-03T04:21:04Z")

</div>

Perhaps there should be a warning for setting `JULIA_NUM_THREADS` during a session?  
I made a suggested PR. There may be a more efficient way to do it [Warn if setting env variable is ineffective during a julia session by IanButterworth · Pull Request #34970 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/34970)

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [March 3, 2020, 4:33am UTC](https://discourse.julialang.org/t/setting-nthreads-using-the-julia-config-startup-jl-file/35427/24 "2020-03-03T04:33:18Z")

</div>

Adding a warning without a way to disable it is almost always a bad idea.

[Previous page](https://discourse.julialang.org/t/setting-nthreads-using-the-julia-config-startup-jl-file/35427.md?page=1)
