# Why can Julia spawn new processes but not new threads?

**URL:** <https://discourse.julialang.org/t/why-can-julia-spawn-new-processes-but-not-new-threads/123267>\
**Category:** Internals & Design\
**Tags:** question, multithreading, distributed, threads, multiprocessing\
**Created:** [November 29, 2024, 9:21pm UTC](https://discourse.julialang.org/t/why-can-julia-spawn-new-processes-but-not-new-threads/123267 "2024-11-29T21:21:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NonDairyNeutrino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nondairyneutrino/32/221496_2.png) [@NonDairyNeutrino](https://discourse.julialang.org/u/NonDairyNeutrino)\
**Post date:** [November 29, 2024, 9:21pm UTC](https://discourse.julialang.org/t/why-can-julia-spawn-new-processes-but-not-new-threads/123267/1 "2024-11-29T21:21:30Z")

</div>

With [Distributed.jl](https://docs.julialang.org/en/v1/stdlib/Distributed/), you can create new worker processes easily with `addprocs` (each of which can have multiple threads), but once a Julia process starts you can’t add more _threads_ to that process; why?

---

<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:** [November 30, 2024, 5:10am UTC](https://discourse.julialang.org/t/why-can-julia-spawn-new-processes-but-not-new-threads/123267/2 "2024-11-30T05:10:57Z")

</div>

New foreign threads can be created already, to facilitate external code that needs dedicated threads.

For instance `Base.Experimental.make_io_thread()` does that [julia/base/experimental.jl at 1ed2b98131cb7074cec5f556f222e8ad023285f9 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/1ed2b98131cb7074cec5f556f222e8ad023285f9/base/experimental.jl#L460-L481)

```julia
julia> Threads.maxthreadid()
1

julia> Base.Experimental.make_io_thread()
true

julia> Threads.maxthreadid()
2

```

But adding/removing threads to/from the user threadpools has not been implemented yet.  
I don’t believe there’s a technical limitation.
