# How to start numerous threads on windows

**URL:** <https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144>\
**Category:** General Usage\
**Created:** [December 11, 2019, 11:14am UTC](https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144 "2019-12-11T11:14:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/diger/32/36786_2.png) [@Diger](https://discourse.julialang.org/u/Diger)\
**Post date:** [December 11, 2019, 11:14am UTC](https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144/1 "2019-12-11T11:14:19Z")

</div>

In the manual it says to use

```julia
$ JULIA_NUM_THREADS=4 ./julia

```

But how to invoke threads on windows with the julia icon?

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [December 11, 2019, 12:10pm UTC](https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144/2 "2019-12-11T12:10:47Z")

</div>

Step 1: Create a .cmd file with

```julia
set JULIA_NUM_THREADS=4
D:\Julia\Julia-1.3.0\bin\julia.exe

```

(change the path as required)

Step 2: right-click the Julia icon, go to “properties” and point to the .cmd file

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 11, 2019, 1:08pm UTC](https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144/3 "2019-12-11T13:08:20Z")

</div>

Paul is of course right, just two additional options:

1. With Windows terminal, the terminal experience is improving, so I’ve moved to actually starting Julia from the terminal (in which case you can do what’s in the manual, just slightly modified):

```julia
PS C:\Users\ngudat> $env:JULIA_NUM_THREADS = 4
PS C:\Users\ngudat> julia
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.3.0-rc5.1 (2019-11-17)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

julia> Threads.nthreads()
4

```

1. Juno is by default setting the number of threads to the number of cores on your system, so if you’re using Julia through Juno there’s nothing to be done.

---

<div class="post-metadata">

**Author:** ![Diger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/diger/32/36786_2.png) [@Diger](https://discourse.julialang.org/u/Diger)\
**Post date:** [December 12, 2019, 8:36am UTC](https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144/4 "2019-12-12T08:36:58Z")

</div>

Thanks. Can I not start more Threads than cores on my CPU?  
If I set threads to 8 in the batchfile, the number of threads  
Threads.nthreads()  
will still give 4?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [December 12, 2019, 8:45am UTC](https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144/5 "2019-12-12T08:45:35Z")

</div>

[https://docs.julialang.org/en/v1/manual/environment-variables/index.html#JULIA\_NUM\_THREADS-1](https://docs.julialang.org/en/v1/manual/environment-variables/index.html#JULIA_NUM_THREADS-1)

---

<div class="post-metadata">

**Author:** ![Diger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/diger/32/36786_2.png) [@Diger](https://discourse.julialang.org/u/Diger)\
**Post date:** [December 12, 2019, 8:47am UTC](https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144/6 "2019-12-12T08:47:56Z")

</div>

Right. Is it possible to run Threads on my GPU?

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [December 12, 2019, 11:58am UTC](https://discourse.julialang.org/t/how-to-start-numerous-threads-on-windows/32144/7 "2019-12-12T11:58:36Z")

</div>

That is actually a damn good question…  
The short answer: [https://juliagpu.gitlab.io/CuArrays.jl/tutorials/generated/intro/](https://juliagpu.gitlab.io/CuArrays.jl/tutorials/generated/intro/)
