# Does multithreading require a new process?

**URL:** https://discourse.julialang.org/t/does-multithreading-require-a-new-process/45056
**Category:** General Usage
**Created:** [August 16, 2020, 6:35pm UTC](https://discourse.julialang.org/t/does-multithreading-require-a-new-process/45056 "2020-08-16T18:35:12Z")
**Posts on this page:** 1
**Showing post:** 3

<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 17, 2020, 1:53pm UTC](https://discourse.julialang.org/t/does-multithreading-require-a-new-process/45056/3 "2020-08-17T13:53:57Z")

</div>

Julia multithreading works by having Julia create N operating system threads at initialization, and then when you want to run something in parallel you @spawn a task… this task will get bound to a specific thread, and execute in parallel with other tasks on different threads.

it’s not clear to me how tasks get scheduled on a given thread and tasks can’t migrate from thread to thread **yet**.

I actually think you should set the JULIA\_NUM\_THREADS to be the same as your number of actual cores plus a small constant, like 2 or 3. Then you can have a few threads to do UI and file IO type stuff and the OS will take care of scheduling them, without tying up your computation threads.

once Julia can migrate tasks across threads this would be maybe less important.

---

_[View the full topic](https://discourse.julialang.org/t/does-multithreading-require-a-new-process/45056)._
