# Multi-threaded Array building

**URL:** <https://discourse.julialang.org/t/multi-threaded-array-building/132463>\
**Category:** Performance\
**Tags:** multithreading\
**Created:** [September 17, 2025, 12:23pm UTC](https://discourse.julialang.org/t/multi-threaded-array-building/132463 "2025-09-17T12:23:14Z")\
**Posts on this page:** 1\
**Showing post:** 9

<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:** [September 17, 2025, 3:15pm UTC](https://discourse.julialang.org/t/multi-threaded-array-building/132463/9 "2025-09-17T15:15:00Z")

</div>

> [@FerreolS](#):
>
> What is now (with julia 1.10 or 1.11) the best way to multithread that kind of array building function?

You could

1. Use `task_local_storage` to have a per-task array (rather than per-thread). e.g. [No more threadid indexing? [thread-local storage] - #12 by stevengj](https://discourse.julialang.org/t/no-more-threadid-indexing-thread-local-storage/131535/12)
2. Use ChunkSplitters.jl (ala [Why has simple threading using `threadid` become so complex in v1.12...? - #28 by foobar\_lv2](https://discourse.julialang.org/t/why-has-simple-threading-using-threadid-become-so-complex-in-v1-12/129135/28)) to create a per-chunk array. (This has the downside of imposing essentially a static parallelization schedule, which might be bad if `processing(B[idx])` could take a very different amount of time depending on the argument.)
3. Use some higher-level primitives like in OhMyThreads.jl or Transducers.jl, e.g. expressing this as a parallel reduction operation.

---

_[View the full topic](https://discourse.julialang.org/t/multi-threaded-array-building/132463)._
