# Question for lower performance by using @threads in for loop

**URL:** <https://discourse.julialang.org/t/question-for-lower-performance-by-using-threads-in-for-loop/64315>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [July 9, 2021, 1:17am UTC](https://discourse.julialang.org/t/question-for-lower-performance-by-using-threads-in-for-loop/64315 "2021-07-09T01:17:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![brenhinkeller](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brenhinkeller/32/36648_2.png) [@brenhinkeller](https://discourse.julialang.org/u/brenhinkeller)\
**Post date:** [July 9, 2021, 1:25am UTC](https://discourse.julialang.org/t/question-for-lower-performance-by-using-threads-in-for-loop/64315/2 "2021-07-09T01:25:36Z")

</div>

Threads can have have pretty high overhead – see for example

> <https://stackoverflow.com/questions/63933356/julia-threads-threads-slower-than-single-thread-performance/68310079#68310079>

> [@Julia Threads.@threads slower than single thread performance](https://discourse.julialang.org/t/julia-threads-threads-slower-than-single-thread-performance/46823):
>
> I am trying to solve numerically the heat equation in 1d: [[enter image description here]](https://i.stack.imgur.com/8GbwB.gif) I am using finite differences and I have some trouble using the @threads instruction in Julia. In particular below there are two version of the same code: the first one is single thread while the other uses @threads (they are identical apart from the @thread instruction) function heatSecLoop(;T::Float64) println("start") L = 1 ν = 0.5 Δt = 1e-6 Δx = 1e-3 Nt = ceil(Int, T/Δt ) …

---

_[View the full topic](https://discourse.julialang.org/t/question-for-lower-performance-by-using-threads-in-for-loop/64315)._
