# Trying to read from a HDF5 file and convert to another format in parallel?

**URL:** <https://discourse.julialang.org/t/trying-to-read-from-a-hdf5-file-and-convert-to-another-format-in-parallel/112479>\
**Category:** General Usage\
**Created:** [April 3, 2024, 5:30pm UTC](https://discourse.julialang.org/t/trying-to-read-from-a-hdf5-file-and-convert-to-another-format-in-parallel/112479 "2024-04-03T17:30:30Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [April 4, 2024, 10:34am UTC](https://discourse.julialang.org/t/trying-to-read-from-a-hdf5-file-and-convert-to-another-format-in-parallel/112479/10 "2024-04-04T10:34:40Z")

</div>

Just to be clear, the following thread-parallel writing and reading (of different HDF5 files) works just fine (because of the lock mentioned by @mkitti):

```julia
@sync for t in 1:nthreads()
    @spawn h5open("file$t.h5", "w") do f
        for i in 1:100
            f[string(i)] = rand(1000, 1000)
        end
    end
end

@sync for t in 1:nthreads()
    @spawn h5open("file$t.h5", "r") do f
        s = 0.0
        for i in 1:100
            s += sum(read(f[string(i)]))
        end
        @show t, s
    end
end

```

It’s hence not clear - at least not to me - where the segfault in the OP is coming from.

---

_[View the full topic](https://discourse.julialang.org/t/trying-to-read-from-a-hdf5-file-and-convert-to-another-format-in-parallel/112479)._
