What is the package that keeps the threads open in the pool for future call?

I know that $OMP in OpenMP open the specified threads and assign tasks for them as demanded. However, after finishing the threads stay open in the pool. So, any future call to the threads will call them from the pool (as they are not closed) and no overhead will be consumed again.
What is the package and directive in Julia that do the same by keep the threads in the pool after the first call?

There is no such package, but have a look at GitHub - tro3/ThreadPools.jl: Improved thread management for background and nonuniform tasks in Julia. Docs at https://tro3.github.io/ThreadPools.jl and GitHub - JuliaSIMD/Polyester.jl: The cheapest threads you can find! .

For searching packages use JuliaHub .

In general, Julia doesn’t dynamically create and destroy threads. The threads are created when you start Julia and don’t go anywhere over the lifetime of your program.

(Technically, this isn’t true for Julia 1.9 anymore, but only in very rare and specific cases that we certainly aren’t talking about here.)

Thank you very your note.
This means that in Julia the macro @threads opens threads and its end kills the threads?
From you experience, if I have multi-threading within a time simulation, which package/directive suites this case to reduce the overhead of launching the threads and closing them?

for t_min:dt:t_max
@thread for i in 1:nthreads()  # open threads
#Do work
end                            # close threads
end

Actually, I tried those packages but did not have real benefit comparing with @spawn or @threads

  • So, after starting Julia there is no future overheads resulting from opening/closing threads (in @threads/@tspawnat as an example)?

  • If I run julia -t 3, and I used multi-threading (static scheduling) within a time simulation as in the below:
    1- If CPU-0, CPU-1, CPU-2 are created in the Julia startup (out of the 6 cores that in my machine), so they are the only ones that will be calling within the time simulation?
    2- From your experience, which package/directive suites this case to reduce the overheads of threads?

for t_min:dt:t_max
@thread :static for i in 1:nthreads()  # open threads
#Do work
end                            # close threads
end