Thread safety
Thread safety is the property of code or shared state remaining correct when accessed concurrently by multiple threads.
Functional Design and Architecture: Examples in Haskell
Thread safety is the property that shared code or data remains correct when accessed concurrently by multiple threads.
- How it is used
- Motivates disciplined shared-state and thread-management design in concurrent applications.
- How deep it goes
- Explains races, atomic variables, STM transactions, layered process control, and state granularity without detailing STM properties.
- Examples
- Uses a meteor-reporting channel, restricted process language, and nested-MVar key-value simulator state.
- What you can do after
- Evaluate/understand where shared-state designs can race, overload resources, or benefit from transactional or fine-grained coordination.
Read how Functional Design and Architecture: Examples in Haskell explains thread safety →
Learn Go with Pocket-Sized Projects
Thread safety is the property that permits concurrent execution by multiple threads without causing incorrect behavior or data races.
- How it is used
- Evaluates whether shared caches and other library components remain correct when concurrent execution paths access them.
- How deep it goes
- Explains shared-resource hazards and concurrent testing, then points to mutexes without detailing synchronization implementation.
- Examples
- Uses a map-backed generic cache, simultaneous cache updates, and a water-bottle analogy for conflicting shared access.
- What you can do after
- Diagnose/debug with it by testing concurrent cache calls and deciding whether synchronization is required.
Read how Learn Go with Pocket-Sized Projects explains thread safety →
Rust Servers, Services, and Apps
Thread safety is the property that shared program behavior remains correct when accessed concurrently by multiple threads.
- How it is used
- Uses thread safety to explain Rust’s suitability for backend applications and infrastructure services.
- How deep it goes
- Identifies race-condition prevention but does not explain implementation mechanisms.
- What you can do after
- Understand how Rust thread safety helps prevent race conditions and concurrency bugs.
Read how Rust Servers, Services, and Apps explains thread safety →
C# Concurrency: Asynchronous and multithreaded programming
Thread safety is the property that data and operations remain correct when accessed or modified concurrently by multiple threads.
- How it is used
- Uses thread safety to coordinate shared state and prevent races in multithreaded code.
- How deep it goes
- Explains lock scope, ordering, compiler and CPU reordering, and immutable alternatives; defers advanced Interlocked examples.
- Examples
- Uses operand updates, separate locks, ordering figures, and an immutable collection model analogous to String.
- What you can do after
- Diagnose/debug with it by identifying races, inconsistent lock scopes, unsafe ordering, and incomplete protection around Interlocked accesses.
Read how C# Concurrency: Asynchronous and multithreaded programming explains thread safety →
Python Concurrency with asyncio
Thread safety is the property of behaving correctly when accessed or modified concurrently by multiple threads.
- How it is used
- Uses thread safety to explain correct shared-state access, race conditions, locks, and responsive threaded applications.
- How deep it goes
- Explains race conditions through read-modify-write behavior and demonstrates intermittent failures, without detailing atomic-operation rules.
- Examples
- Demonstrates unsafe shared counters, simultaneous reference-count increments, and CPU-bound Fibonacci work with and without threads.
- What you can do after
- Apply it by protecting shared updates with locks and recognizing when concurrent code can produce nondeterministic results.
Read how Python Concurrency with asyncio explains thread safety →
100 Java Mistakes and How to Avoid Them
Thread safety is the property that concurrent execution by multiple threads preserves an object's or component's correctness and consistency.
- How it is used
- Flags accidental sharing of mutable state across concurrent Java threads.
- How deep it goes
- Explains static-field failure through a TreeWalker example and gives prevention checks, without detailing synchronization mechanisms.
- Examples
- Uses Person's static name field and TreeWalker's static processing queue to illustrate accidental sharing.
- What you can do after
- Diagnose suspicious shared state with IDE highlighting, static-analysis warnings, and integration tests that emulate concurrent use.
Read how 100 Java Mistakes and How to Avoid Them explains thread safety →
Grokking Concurrency
Thread safety is the property of a function or operation behaving correctly when accessed concurrently by multiple tasks under any scheduling or interleaving.
- How it is used
- Guides safe access to shared resources when concurrent tasks may interleave their operations.
- How deep it goes
- Defines correctness, demonstrates race conditions, and weighs synchronization costs without developing immutable or pure-function methods.
- Examples
- Uses a shared printer, an unsynchronized bank account, concurrent ATMs, timing delays, and incorrect account balances.
- What you can do after
- Diagnose possible race conditions by perturbing timing and protect unsafe shared access through synchronization or reduced sharing.
Code Like a Pro in Rust
Thread safety is the property that concurrent access to a value or operation preserves its correctness without data races or invalid state transitions.
- How it is used
- Handles shared state and global counters safely during multithreaded Rust tests.
- How deep it goes
- Traces compiler errors through atomics, Arc, and lazy initialization, then demonstrates Mutex-based test serialization.
- Examples
- Uses a mutable static counter, atomic counter, Arc-wrapped counter, lazy_static expansion, and locked parallel tests.
- What you can do after
- Apply Rust synchronization primitives to compile and run shared-state tests without data races or invalid static initialization.
Related concepts
- synchronizationconfigured by · Synchronization coordinates operations, events, clocks, data, or states to establish required timing, ordering, visibility, or consistency relationships.
- race conditioncontrasts with · A race condition is a concurrency defect in which program behavior or results depend on the relative timing or ordering of interacting operations.
- immutable collectionaddressed by · An immutable collection is a collection whose membership and contents cannot be changed after creation.
- pure functionuses · A pure function is a function whose output is determined solely by its explicit inputs and whose evaluation has no externally observable side effects.
- distributed lockaddressed by · A distributed lock is a coordination mechanism that grants mutually exclusive access to a shared resource among processes or machines in a distributed system.
- concurrent collectionaddressed by · A concurrent collection is a collection designed to support safe, defined access or modification by multiple concurrent computations.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.







