# Spurious allocations with @threads, when setting variables using if statements

**URL:** <https://discourse.julialang.org/t/spurious-allocations-with-threads-when-setting-variables-using-if-statements/82233>\
**Category:** General Usage\
**Tags:** threads, potential-bug\
**Created:** [June 4, 2022, 11:50am UTC](https://discourse.julialang.org/t/spurious-allocations-with-threads-when-setting-variables-using-if-statements/82233 "2022-06-04T11:50:38Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 6, 2022, 12:45pm UTC](https://discourse.julialang.org/t/spurious-allocations-with-threads-when-setting-variables-using-if-statements/82233/6 "2022-06-06T12:45:27Z")

</div>

This is probably the infamous bug of the performance penalty of closures, related to `@threads` creating a closure.

See: [Type-instability because of @threads boxing variables](https://discourse.julialang.org/t/type-instability-because-of-threads-boxing-variables/78395)

---

_[View the full topic](https://discourse.julialang.org/t/spurious-allocations-with-threads-when-setting-variables-using-if-statements/82233)._
