# Is static scheduling available in Julia multi-threading?

**URL:** <https://discourse.julialang.org/t/is-static-scheduling-available-in-julia-multi-threading/94970>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 21, 2023, 4:28pm UTC](https://discourse.julialang.org/t/is-static-scheduling-available-in-julia-multi-threading/94970 "2023-02-21T16:28:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [February 21, 2023, 4:28pm UTC](https://discourse.julialang.org/t/is-static-scheduling-available-in-julia-multi-threading/94970/1 "2023-02-21T16:28:05Z")

</div>

I want to use multi-threading (with `@spawn/@thread`) in a static scheduling to prevent threads jumping during the time-loop in this MWE, `nthreads()=2` here:

```julia
using .Threads
function f_spawn()
   thrs = [Threads.@spawn begin
    for t in 1:3
      if threadid() == 1
        println("Iteration $t -First Section -Hi from $(threadid())")
      end
      println("Iteration $t -Execution Section -Hi from $(threadid())")
    end
  end for i = 1:nthreads()];
  fetch.(thrs);
end 
f_spawn()

```

I expect the results to be:

```julia
Iteration 1 -First Section -Hi from 1
Iteration 1 -Execution Section -Hi from 1
Iteration 1 -Execution Section -Hi from 2

Iteration 2 -First Section -Hi from 1
Iteration 2 -Execution Section -Hi from 1
Iteration 2 -Execution Section -Hi from 2

Iteration 3 -First Section -Hi from 1
Iteration 3 -Execution Section -Hi from 1
Iteration 3 -Execution Section -Hi from 2

```

However, they are:

```julia
Iteration 1 -Execution Section -Hi from 2
Iteration 1 -Execution Section -Hi from 2

Iteration 2 -Execution Section -Hi from 2
Iteration 2 -First Section -Hi from 1
Iteration 2 -Execution Section -Hi from 1

Iteration 3 -Execution Section -Hi from 2
Iteration 3 -First Section -Hi from 1
Iteration 3 -Execution Section -Hi from 2

```
