# Behavior of threads

**URL:** <https://discourse.julialang.org/t/behavior-of-threads/95769>\
**Category:** General Usage\
**Tags:** multithreading\
**Created:** [March 8, 2023, 9:07pm UTC](https://discourse.julialang.org/t/behavior-of-threads/95769 "2023-03-08T21:07:33Z")\
**Posts on this page:** 1\
**Showing post:** 32

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [March 24, 2023, 4:55pm UTC](https://discourse.julialang.org/t/behavior-of-threads/95769/32 "2023-03-24T16:55:38Z")

</div>

I think in the first code fragment `@sync` is not needed, actually?

I elaborated these ideas in an application. The algorithm based on tasks does not work very well. Some of the tasks tend to take quite a bit longer than others. Perhaps you are onto something with the spawning?

> <https://github.com/PetrKryslUCSD/FinEtoolsHeatDiff.jl/blob/d041cd06035547e7bdb1422a94daf006594f1393/examples/steady_state/3-d/Poisson_examples.jl#L336>

The threaded version actually works quite well.

> <https://github.com/PetrKryslUCSD/FinEtoolsHeatDiff.jl/blob/d041cd06035547e7bdb1422a94daf006594f1393/examples/steady_state/3-d/Poisson_examples.jl#L479>

Some scaling data is provided in this thread: [Parallel assembly of a finite element sparse matrix - #19 by PetrKryslUCSD](https://discourse.julialang.org/t/parallel-assembly-of-a-finite-element-sparse-matrix/95947/19)

---

_[View the full topic](https://discourse.julialang.org/t/behavior-of-threads/95769)._
