# PSA: Thread-local state is no longer recommended; Common misconceptions about threadid() and nthreads()

**URL:** <https://discourse.julialang.org/t/psa-thread-local-state-is-no-longer-recommended-common-misconceptions-about-threadid-and-nthreads/101274>\
**Category:** General Usage\
**Tags:** announcement, multithreading\
**Created:** [July 6, 2023, 6:12pm UTC](https://discourse.julialang.org/t/psa-thread-local-state-is-no-longer-recommended-common-misconceptions-about-threadid-and-nthreads/101274 "2023-07-06T18:12:08Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![pitsianis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pitsianis/32/26588_2.png) [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Post date:** [July 6, 2023, 9:28pm UTC](https://discourse.julialang.org/t/psa-thread-local-state-is-no-longer-recommended-common-misconceptions-about-threadid-and-nthreads/101274/3 "2023-07-06T21:28:39Z")

</div>

Thank you for this write-up.

Can you provide some comments for the following cases:

- When the running time of each iteration is very unpredictable, how can one select a good value for the `chunks_per_thread`?

- What can be done with nested loops that can be parallelized?

There is a very elegant solution to these problems employed by `cilk_for` of `OpenCilk` with work stealing and a loop grainsize hint. Can we utilize such techniques with Julia as well?

---

_[View the full topic](https://discourse.julialang.org/t/psa-thread-local-state-is-no-longer-recommended-common-misconceptions-about-threadid-and-nthreads/101274)._
