The following MWE indicates that within a single julia instance:
- concurrent access to (thread-specific) sub-arrays is fine
- threaded IO via Base.Filesystem is fine
N = 2^20
checklens = Array{Array{Int64,1},1}(undef,Threads.nthreads())
for i in 1:length(checklens)
checklens[i] = Array{Int64,1}(undef,0)
end
Threads.@threads for i in 1:N
check=Base.Filesystem.readdir("/tmp/")
push!(checklens[Threads.threadid()],length(check))
end
test
@testset "single instance" begin
@test reduce(==,reduce(vcat,checklens))
@test length(reduce(vcat,checklens)) == N
end
Test Summary: | Pass Total
single instance | 2 2
Test.DefaultTestSet("single instance", Any[], 2, false)
Will this also work with separate (threaded) julia instances?
I’m not sure how to write a test for that.