# Understanding use of interactive thread pool

**URL:** <https://discourse.julialang.org/t/understanding-use-of-interactive-thread-pool/109815>\
**Category:** General Usage\
**Tags:** question, multithreading\
**Created:** [February 6, 2024, 3:07pm UTC](https://discourse.julialang.org/t/understanding-use-of-interactive-thread-pool/109815 "2024-02-06T15:07:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![samtkaplan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samtkaplan/32/2000_2.png) [@samtkaplan](https://discourse.julialang.org/u/samtkaplan)\
**Post date:** [February 6, 2024, 3:07pm UTC](https://discourse.julialang.org/t/understanding-use-of-interactive-thread-pool/109815/1 "2024-02-06T15:07:55Z")

</div>

Hello,

I am trying to understand when the “interactive” thread pool is used vs when the “default” thread pool is used. My expectation is that the “default” thread pool is used unless we explicitly ask for the interactive thread pool. Indeed, the [documentation](https://docs.julialang.org/en/v1/manual/multi-threading/#man-threadpools) seems to indicate that this is the case. But, the following code,

```julia
julia -t 1,1 -e 'print(stdout, "$(Threads.threadpool())\n")'

```

gives,

```julia
interactive

```

It is surprising to me that by **default** the interactive thread is used. I can work-a-round this by doing:

```julia
julia -t 1,1 -e 'wait(Threads.@spawn print(stdout, "$(Threads.threadpool())\n"))'

```

but, it seems that this should not be needed, it doesn’t match with the documentation, and this work-a-round is often inconvenient.

I am using Julia 1.10, and Ubuntu 22.04. Any thoughts? Am I doing something wrong, or is the behavior wrong, or is the documentation incorrect?

I identified this problem while trying to run some code in an interactive thread, and noticing that it did not appear to be interactive 🙂 .

Many thanks!

Sam

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [February 6, 2024, 6:50pm UTC](https://discourse.julialang.org/t/understanding-use-of-interactive-thread-pool/109815/2 "2024-02-06T18:50:05Z")

</div>

Threads that you spawn are all in the `:default` thread pool by default. ~~The thread that you work on in the interactive REPL is, of course, an interactive thread.~~

---

<div class="post-metadata">

**Author:** ![samtkaplan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samtkaplan/32/2000_2.png) [@samtkaplan](https://discourse.julialang.org/u/samtkaplan)\
**Post date:** [February 6, 2024, 6:58pm UTC](https://discourse.julialang.org/t/understanding-use-of-interactive-thread-pool/109815/3 "2024-02-06T18:58:46Z")

</div>

Hi @carstenbauer

Thanks so much for your response. What you say makes sense, but it doesn’t seem to match what I observe. For example, when I try the following code:

```julia
julia -t 1,1 -e 'Threads.threadid() in Threads.threadpooltids(:interactive) ? println("interactive") : println("default"); println(isinteractive())'

```

I see,

```julia
interactive
false

```

The first line in the output indiicates that we are using the interactive thread, and the second line is just to confrim that we are not running in interactive mode.

Can I trouble you to try running the same code. Perhaps there is something wrong with my setup.

Many thanks!

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [February 6, 2024, 7:59pm UTC](https://discourse.julialang.org/t/understanding-use-of-interactive-thread-pool/109815/4 "2024-02-06T19:59:25Z")

</div>

Turns out the documentation is wrong.

```julia
julia -t 3 -E 'Threads.threadpool()'
:default

```

```julia
julia -t 3,1 -E 'Threads.threadpool()'
:interactive

```

This change in behavior is surprising to me and the latter case is in contrast to what the documentation says.

Might, perhaps, be related to the fact that the ordering of thread ids changed (kind of last minute) from “default first, then interactive” to “interactive first, then default”. Would you mind filing an issue on github?

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [February 6, 2024, 8:00pm UTC](https://discourse.julialang.org/t/understanding-use-of-interactive-thread-pool/109815/5 "2024-02-06T20:00:13Z")

</div>

My first reply was (partially) incorrect, as demonstrated in my post above. I’ve striked out the corresponding part.

---

<div class="post-metadata">

**Author:** ![samtkaplan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samtkaplan/32/2000_2.png) [@samtkaplan](https://discourse.julialang.org/u/samtkaplan)\
**Post date:** [February 6, 2024, 8:35pm UTC](https://discourse.julialang.org/t/understanding-use-of-interactive-thread-pool/109815/6 "2024-02-06T20:35:59Z")

</div>

Thanks @carstenbauer. Here is the GitHub issue: [Surprising behavior for default/interactive thread pools · Issue #53217 · JuliaLang/julia (github.com)](https://github.com/JuliaLang/julia/issues/53217)
