‌Basic question about Threads.@threads and multithreading

Hello everybody.

I’m very new to Julia. I read documents and many topics in the discourse still I’m not sure I’m doing right.
I want to implement the 2 sets of equations in multi-threads.
my equations something like that

#------First Set------
1.ex = ex + aE1 + aX
2.ey = ey + bE2 + bX
3.ey = ey + cE3 + cX
#------Second Set------
4.E1 = ex + E1
5.E1 = ey + E1
6.E1 = ez + E1

I want to run 1,2,3 (at the same time), then 4,5,6, simultaneously.
what I do in Julia:

function calculate_E(fields)
 Threads.@threads for i in 1:(c_x)
            for j in 2:(c_y)
                for k in 2:(c_z-1)
                      k_x[i,j,k] = k_x[i,j,k]+ a[i,j,k]*E1[i,j,k] + a[i,j,k]*X[i,j,k]
                end
            end
        end

 Threads.@threads for i in 2:(c_x-1)
            for j in 1:(c_y)
                for k in 2:(c_z)
                      k_y[i,j,k] = k_y[i,j,k]+ a[i,j,k]*E2[i,j,k] + a[i,j,k]*X[i,j,k]
                end
            end
        end

 Threads.@threads for i in 2:(c_x)
            for j in 2:(c_y-1)
                for k in 1:(c_z)
                      k_z[i,j,k] = k_z[i,j,k]+ a[i,j,k]*E3[i,j,k] + a[i,j,k]*X[i,j,k]
                end
            end
        end
end

function aux_field(fields)

        Threads.@threads for i in 1:(c_x)
            for j in 2:(c_y)
                for k in 2:(c_z)
                    E1[i,j,k] = k_x[i,j,k] + E1[i,j,k]
                end
            end
        end

        Threads.@threads for i in 2:(c_x)
            for j in 1:(c_y)
                for k in 2:(c_z)
                    E2[i,j,k] = k_y[i,j,k] + E2[i,j,k]
                end
            end
        end

        Threads.@threads for i in 2:(c_x)
            for j in 2:(c_y)
                for k in 1:(c_z)
                    E1[i,j,k] = k_z[i,j,k] + E1[i,j,k]
                end
            end
        end

end

   @time for time in 1:t
            k_x, k_y, k_z=calculate_ex(k_x, k_y, k_z, E1, E2, E3)

            E1, E2, E3=aux_field(k_x, k_y, k_z, E1, E2, E3)
    end

am I do it right? When I use Threads.@threads in those functions?

and another question in the function “aux_field” in single threads I can simply write:

E1 = ex + E1
E1 = ey + E1
E1 = ez + E1

Is there a way to make them multithreading without for loops, and it’s even feasible?

P.S. my code’s answers are correct.

Thanks

It’ll be easier for others to respond to your question if you can provide a minimal working example (including definitions for all your variables) that can be copy-pasted into the REPL. As it stands, I can’t guess the eltypes or dimensions of any of your variables, which makes it hard to provide any specific advice.