In multithreading, how to make each thread pick the first/smallest available element?

@threads :static divides the range into packs 1:n/nthreads, n/nthreads+1:2n/nthreads

For example with four threads and a range divisible by four you get

julia> A = Vector{Int64}(undef, 16);

julia> Threads.@threads for i=1:16
           A[i] = Threads.threadid();
       end

julia> A
16-element Vector{Int64}:
 1
 1
 1
 1
 2
 2
 2
 2
 3
 3
 3
 3
 4
 4
 4
 4

If you want [1,5,9,13] to be scheduled on e.g. thread 1, you would need to do your own task wrapping and scheduling.