thread-safe code

noun phrase
UK /θrɛd seɪf kəʊd/
US /θrɛd seɪf koʊd/

Code that is safe to use when many parts of a program run at the same time.

The library provides thread-safe code so multiple workers can update the cache without errors.


OTHER MEANINGS

2. Code designed to avoid data races when accessed concurrently.

Reviewers flagged the shared counter as not thread-safe code.

3. Software that protects shared state with locks or atomic operations.

Switching to thread-safe code fixed the intermittent crashes.

4. A property of functions that can be called from multiple threads safely.

The logging utility is thread-safe code, so every thread can write to it.