# Recommendation for thread-safe file access (ex .jld2)

**URL:** <https://discourse.julialang.org/t/recommendation-for-thread-safe-file-access-ex-jld2/44585>\
**Category:** New to Julia\
**Created:** [August 8, 2020, 8:28pm UTC](https://discourse.julialang.org/t/recommendation-for-thread-safe-file-access-ex-jld2/44585 "2020-08-08T20:28:41Z")\
**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:** [August 8, 2020, 8:28pm UTC](https://discourse.julialang.org/t/recommendation-for-thread-safe-file-access-ex-jld2/44585/1 "2020-08-08T20:28:41Z")

</div>

I have a for loop that uses the @threads macro, here is a simple example:

```julia
Threads.@threads for i in 1:10
    checks = load("myfile.jld2")["checks"]
    push!(checks,(i,i+1))
    @save "myfile.jld2" checks
end

```

Currently this does not work, presumably because the different threads are unable to wait for each other when accessing the file.

Is there a recommended way to intermittently back up results of a threaded loop to a file?
