# Base.Filesystem concurrency for separate julia instances

**URL:** <https://discourse.julialang.org/t/base-filesystem-concurrency-for-separate-julia-instances/46113>\
**Category:** New to Julia\
**Tags:** question, parallel, filesystem\
**Created:** [September 5, 2020, 5:09pm UTC](https://discourse.julialang.org/t/base-filesystem-concurrency-for-separate-julia-instances/46113 "2020-09-05T17:09:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [September 5, 2020, 5:09pm UTC](https://discourse.julialang.org/t/base-filesystem-concurrency-for-separate-julia-instances/46113/1 "2020-09-05T17:09:57Z")

</div>

The following MWE indicates that within a single julia instance:

1. concurrent access to (thread-specific) sub-arrays is fine
2. threaded IO via Base.Filesystem is fine

```julia
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**
>
> ```julia
> @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.
