Pure Functions and Thread Safety
Pure functions are a strong design option in concurrent code because they depend only on their inputs and produce no side effects. With no shared mutable state to read or update, multiple threads can call the same function safely without locks.
Interview-ready answer
Prefer pure functions for computation-heavy parts of a design. They are naturally thread-safe, deterministic, easy to test, and eliminate an entire class of race conditions caused by shared mutable state.
They do not remove the need for synchronization everywhere: stateful boundaries—such as caches, databases, queues, and counters—still need explicit concurrency control. A good design keeps those boundaries small and pushes as much logic as possible into pure functions.