julia> Threads.@threads for (index, value) in enumerate([1,2])
end
ERROR: TaskFailedException
Stacktrace:
[1] wait
@ .\task.jl:322 [inlined]
[2] threading_run(func::Function)
@ Base.Threads .\threadingconstructs.jl:34
[3] top-level scope
@ .\threadingconstructs.jl:93
nested task error: MethodError: no method matching firstindex(::Base.Iterators.Enumerate{Vector{Int64}})
Closest candidates are:
firstindex(::Any, ::Any) at abstractarray.jl:366
firstindex(::Pair) at pair.jl:63
firstindex(::UnitRange) at range.jl:567
...
Stacktrace:
[1] (::var"#36#threadsfor_fun#3"{Base.Iterators.Enumerate{Vector{Int64}}})(onethread::Bool)
@ Main .\threadingconstructs.jl:66
[2] (::var"#36#threadsfor_fun#3"{Base.Iterators.Enumerate{Vector{Int64}}})()
@ Main .\threadingconstructs.jl:48
My current work around:
julia> Threads.@threads for (index, value) in collect(enumerate([1,2]))
end