Limit number of threads from Threads.@threads

Something like this?

function inner()
    # memory intensive code that is multithreaded
end

function outer()
    Threads.@threads for i in 1:3
        for j in i:3:100
            @show i, j
            inner() # I only want a few `i` to run here
        end
    end
end
1 Like