# Question about optimal thread allocation for vector of problems of differing sizes

**URL:** <https://discourse.julialang.org/t/question-about-optimal-thread-allocation-for-vector-of-problems-of-differing-sizes/33464>\
**Category:** Performance\
**Tags:** multithreading\
**Created:** [January 16, 2020, 11:10pm UTC](https://discourse.julialang.org/t/question-about-optimal-thread-allocation-for-vector-of-problems-of-differing-sizes/33464 "2020-01-16T23:10:43Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [January 17, 2020, 12:02am UTC](https://discourse.julialang.org/t/question-about-optimal-thread-allocation-for-vector-of-problems-of-differing-sizes/33464/3 "2020-01-17T00:02:54Z")

</div>

FYI with Transducers.jl it’s `reduce(right, Map(do_problem), v; basesize=1)` where `basesize=1` means to process one item per thread (see [Thread- and process-based parallelisms in Transducers.jl (+ some news)](https://discourse.julialang.org/t/thread-and-process-based-parallelisms-in-transducers-jl-some-news/32285))

> [@Jakub\_Wronowski](#):
>
> ```julia
> for i in 1:16; Threads.@spawn
> 
> ```

It’s better to wrap it with `@sync`, as in `@sync for i in 1:16; Threads.@spawn ...` so that the next code is run only after all the tasks are finished.

---

_[View the full topic](https://discourse.julialang.org/t/question-about-optimal-thread-allocation-for-vector-of-problems-of-differing-sizes/33464)._
