Multi-threading on for loop with mutation operations in julia

I am trying to run the below mentioned code for loop using @threads for multi-threading, however the results always portray an error of mismatching number of outputs.

using Combinatorics, Base.Threads
import Base.Threads.@threads
func(x, y)
result = Float64[]
a = Float64[]
@threads for c in combinations(1:n, 2)
        a, b = c
        result = func(a, b)
        push!(result, result)
        push!(a, a)     

The error observed during the processing:

DimensionMismatch("column :result has length 60 and column :a has length 50")

Please suggest an approach which make sure that no mutations from the loop are missed.

Read more here:

Content Attribution

This content was originally published by Mohammad Saad at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: