# Does writing in parallel block the whole process?

**URL:** https://discourse.julialang.org/t/does-writing-in-parallel-block-the-whole-process/134620
**Category:** Internals & Design
**Tags:** question, multithreading, task, io, serialization
**Created:** [December 17, 2025, 8:28pm UTC](https://discourse.julialang.org/t/does-writing-in-parallel-block-the-whole-process/134620 "2025-12-17T20:28:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![NonDairyNeutrino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nondairyneutrino/32/221496_2.png) [@NonDairyNeutrino](https://discourse.julialang.org/u/NonDairyNeutrino)
#### Post date: [December 17, 2025, 8:28pm UTC](https://discourse.julialang.org/t/does-writing-in-parallel-block-the-whole-process/134620/1 "2025-12-17T20:28:48Z")

</div>

Say I have a large piece of data `data` that I want to write or serialize (for speed) to a file `file` with `serialize("path/to/file", data)`. Done naively, this will block the rest of the program from executing. So it’s simple enough to create a new task via `@spawn serialize("path/to/file", data)` so the Julia scheduler will execute it on the next available thread.

Now, I happened to read on [Wikipedia page for “Green Threads”](https://en.wikipedia.org/wiki/Green_thread#Performance) (e.g. Julia’s Tasks)

> When a green thread executes a blocking system call, not only is that thread blocked, but all of the threads within the process are blocked.[[5]](https://en.wikipedia.org/wiki/Green_thread#cite_note-5) To avoid that problem, green threads must use [non-blocking I/O](https://en.wikipedia.org/wiki/Non-blocking_I/O) or [asynchronous I/O](https://en.wikipedia.org/wiki/Asynchronous_I/O) operations, although the increased complexity on the user side can be reduced if the [virtual machine](https://en.wikipedia.org/wiki/Virtual_machine) implementing the green threads spawns specific I/O processes (hidden to the user) for each I/O operation.[_[citation needed](https://en.wikipedia.org/wiki/Wikipedia:Citation_needed)_]

So now I’m curious, does serialization execute a blocking system-call? If so, is it non-blocking or being in another thread considered asynchronous I/O? Does LLVM take care of these aspects? Or more directly, **does saving data in parallel actually block the whole process?**

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [December 17, 2025, 9:08pm UTC](https://discourse.julialang.org/t/does-writing-in-parallel-block-the-whole-process/134620/2 "2025-12-17T21:08:15Z")

</div>

The `serialize` function uses Julia’s standard asynchronous I/O routines (`write` etc.), based on the [libuv library](https://github.com/libuv/libuv), so it does not block the whole process.

---

<div class="post-metadata">

### Author: ![NonDairyNeutrino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nondairyneutrino/32/221496_2.png) [@NonDairyNeutrino](https://discourse.julialang.org/u/NonDairyNeutrino)
#### Post date: [December 17, 2025, 9:17pm UTC](https://discourse.julialang.org/t/does-writing-in-parallel-block-the-whole-process/134620/3 "2025-12-17T21:17:13Z")

</div>

To quote Jeff Goldblum,

> [Well, there it is.](https://tenor.com/view/jurassic-park-ian-malcolm-jeff-goldblum-there-it-is-gif-4674754)

Thank you @stevengj !

---

<div class="post-metadata">

### Author: ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)
#### Post date: [December 17, 2025, 9:50pm UTC](https://discourse.julialang.org/t/does-writing-in-parallel-block-the-whole-process/134620/4 "2025-12-17T21:50:32Z")

</div>

There’s some fine print worth noting here: All libuv stuff, including IO, is handled by a dedicated task that’s pinned to the main thread. The thread calling `serialize` will block until it’s been able to wake up the libuv task and hand off the IO. This is usually quick, _unless_ there’s a long-running, non-yielding task running on the main thread and blocking the libuv task. So to make sure everything flows smoothly, make sure that all your tasks regularly hit yield points, if necessary by inserting explicit `yield()` calls in long-running, non-allocating loops.

---

<div class="post-metadata">

### Author: ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)
#### Post date: [December 19, 2025, 8:37pm UTC](https://discourse.julialang.org/t/does-writing-in-parallel-block-the-whole-process/134620/5 "2025-12-19T20:37:43Z")

</div>

There is also a provision for calling actually blocking system calls, without blocking the julia thread, It’s the `@threadcall` macro: [Multi-Threading · The Julia Language](https://docs.julialang.org/en/v1/base/multi-threading/#Base.@threadcall)
