# PSA: Thread-local state is no longer recommended

DevFeed: [PSA: Thread-local state is no longer recommended](<https://devfeed.tech/articles/psa-thread-local-state-is-no-longer-recommended-46339.md>)

Original publisher: [Read original article](<https://julialang.org/blog/2023/07/PSA-dont-use-threadid/index.html>)

Author: Mason Protter; Valentin Churavy; Ian Butterworth; and many helpful contributors

Published: 2023-07-06T00:00:00Z

Content type: article

Language: en

Sources: [JuliaLang - The Julia programming language](<https://devfeed.tech/sources/julialang-the-julia-programming-language.md>)

Topics: [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [race-condition](<https://devfeed.tech/topics/race-condition.md>), [multithreading](<https://devfeed.tech/topics/multithreading.md>), [The Julia Language](<https://devfeed.tech/topics/julia.md>)

Tags: [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrency-bugs](<https://devfeed.tech/tags/concurrency-bugs.md>), [deadlock](<https://devfeed.tech/tags/deadlock.md>), [multithreading](<https://devfeed.tech/tags/multithreading.md>), [thread](<https://devfeed.tech/tags/thread.md>)

## AI overview

A Julia blog post warns that relying on thread-local state and threadid() can produce race conditions because tasks may yield and migrate between tasks on the same thread. It recommends safer task-based patterns for managing and returning state.

## Source excerpt

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