Synchronization
Synchronization is the coordination of concurrent activities, events, or system states to establish required ordering, alignment, access, or consistency relationships.
Grokking Concurrency
Synchronization is coordination that controls access to shared resources and orders task execution so required exclusivity or dependencies are respected.
- How it is used
- Coordinates dependent tasks and protects shared resources in concurrent programs.
- How deep it goes
- Explains critical sections and synchronization primitives, and illustrates competing locks with dining philosophers.
- Examples
- Uses a shared printer, tic-tac-toe turns, and dining philosophers to illustrate coordination.
- What you can do after
- Diagnose race conditions and evaluate synchronization choices for shared resources and task dependencies.
Modern C, Third Edition
A synchronization event is an operation or occurrence that coordinates concurrent execution and can establish an ordering relationship between threads.
- How it is used
- Explains how concurrent threads establish ordering and visibility for shared data.
- How deep it goes
- Works through atomic and library synchronization pairs and consistency tradeoffs, while setting aside memory_order_consume.
- Examples
- Traces two threads modifying an atomic variable and a one-time initialization of a shared error log.
- What you can do after
- Evaluate interthread ordering and visibility through atomic operations and C library synchronization pairs.
100 Go Mistakes and How to Avoid Them
Synchronization is the coordination of concurrent execution so that access to shared state occurs according to required ordering or exclusivity constraints.
- How it is used
- Coordinates goroutines accessing shared resources, passing results between stages, and testing asynchronous publication.
- How deep it goes
- Contrasts mutex exclusivity with channel rendezvous and buffering, then demonstrates synchronization in a test.
- Examples
- Uses a shared slice, a capacity-one channel with two sends, and a mock publisher tested through a channel.
- What you can do after
- Apply it via Go mutexes and channels to protect shared state or coordinate goroutines and asynchronous tests.
Read how 100 Go Mistakes and How to Avoid Them explains synchronization →
Troubleshooting Java, Second Edition
Thread synchronization is the coordination of concurrent threads to control their access to shared state and operations.
- How it is used
- Uses synchronization to investigate concurrency failures and protect shared resources during multithreaded execution.
- How deep it goes
- Demonstrates synchronized blocks and profiler observations, then defers deeper lock relationships to thread dumps and lock profiling.
- Examples
- Uses Java producer and consumer threads that concurrently modify an ArrayList, comparing failing and synchronized executions in VisualVM.
- What you can do after
- Diagnose synchronization failures with VisualVM, thread dumps, sampling, and lock profiling, then protect shared access with synchronized blocks.
Read how Troubleshooting Java, Second Edition explains synchronization →
Latency
A synchronization primitive is an execution mechanism that coordinates concurrent operations and controls access to shared resources.
- How it is used
- Coordinates concurrent access to shared data and propagates optimistic client updates without blocking the UI.
- How deep it goes
- Defines atomic operations as synchronization building blocks and explains Lamport counter updates for reconciling optimistic writes.
- Examples
- Uses geographically partitioned user data, request queues, and a task database with a shadow write queue.
- What you can do after
- Evaluate coordination costs and choose between partitioning, locks, wait-free techniques, and asynchronous reconciliation for the described scenarios.
Go in Action, Second Edition
Synchronization is the coordination of concurrent computations to control their interactions and access to shared state.
- How it is used
- Coordinates goroutine completion and safe access to shared data in concurrent Go programs.
- How deep it goes
- Explains synchronization risks and practical recommendations, but does not work through a complete synchronized implementation.
- Examples
- Uses an RSS reader that launches two feed-fetching goroutines and waits with a fixed sleep.
- What you can do after
- Evaluate/understand how to track goroutine completion and protect shared data.
Read how Go in Action, Second Edition explains synchronization →
C# Concurrency: Asynchronous and multithreaded programming
Synchronization is the coordination of concurrent operations so that they occur in a controlled sequential order rather than simultaneously.
- How it is used
- Coordinates shared operations in multithreaded programs when correctness requires controlled sequencing.
- How deep it goes
- Explains locks, protected regions, waiting, overhead, lock hierarchy, and practical duration trade-offs.
- Examples
- Uses a C# counter with two threads, five-million increments each, lock protection, thread joining, and a performance diagram.
- What you can do after
- Diagnose/debug lost updates and synchronization overhead, then choose safer lock boundaries for shared data.
Read how C# Concurrency: Asynchronous and multithreaded programming explains synchronization →
Grokking GPU Programming
Synchronization is the coordination of concurrent computations so that their execution observes required ordering or completion constraints.
- How it is used
- Coordinates CUDA work when the host or cooperating threads depend on another computation finishing first.
- How deep it goes
- Explains host waits, block barriers, hazard-based placement, and kernel-boundary limits across blocks.
- Examples
- Uses kernel completion, a 1-to-256 reduction, and tiled matrix multiplication to show synchronization failures and fixes.
- What you can do after
- Diagnose missing synchronization by recognizing premature reads, overwrites, inconsistent results, and host exits before kernel completion.
Read how Grokking GPU Programming explains synchronization →
Modern C
Synchronization is the coordination of concurrent execution so that specified operations or events have defined ordering and visibility relationships.
- How it is used
- Coordinates concurrent execution by establishing ordering and visibility relationships between thread operations.
- How deep it goes
- Explains release/acquire pairs, transitive visibility, call_once, mutexes, and happens-before reasoning.
- Examples
- Uses thread creation and joining, detached threads, one-time error-log initialization, and mutex-protected critical sections.
- What you can do after
- Diagnose/debug with it, reason about cross-thread visibility and ordering through happens-before and synchronization pairs.
Python Concurrency with asyncio
Synchronization is the coordination of concurrent operations to control their ordering and access to shared state.
- How it is used
- Coordinates concurrent work, protects shared state, limits resource access, and notifies tasks when conditions change.
- How deep it goes
- Defines race prevention and lock operations, then demonstrates protected updates; it stops short of implementation internals.
- Examples
- Uses a multiprocessing counter, lock acquisition and release, a context manager, database pools, and vendor request limits.
- What you can do after
- Apply it via Python multiprocessing and asyncio primitives to protect updates, constrain concurrency, and coordinate tasks.
Read how Python Concurrency with asyncio explains synchronization →
Advanced Algorithms and Data Structures
Synchronization is the coordination of concurrent operations to control access to shared state and preserve required execution properties.
- How it is used
- Protects shared cache operations from race conditions in a concurrent environment.
- How deep it goes
- Explains race interleavings, atomicity, locks, and Java implementation choices, but stops short of general synchronization algorithms.
- Examples
- Uses concurrent LFU cache insertions, capacity checks, lock acquisition, ConcurrentHashMap, and a synchronized heap.
- What you can do after
- Diagnose race conditions and design lock-protected cache operations using Java concurrency structures.
Read how Advanced Algorithms and Data Structures explains synchronization →
C++ Concurrency in Action, Second Edition
Synchronization is the coordination of operations across threads so their effects are correctly ordered or observed.
- How it is used
- Coordinates thread operations when one must wait for an event, condition, or another task to finish.
- How deep it goes
- Surveys coordination facilities and approaches, then works through a parallel-algorithm race and atomic or mutex alternatives.
- Examples
- Uses parallel for_each calls to contrast independent element updates with a shared counter race.
- What you can do after
- Diagnose shared-state races in parallel algorithms and restore defined behavior with an atomic or mutex, while recognizing possible serialization.
Read how C++ Concurrency in Action, Second Edition explains synchronization →
GPU Programming with Triton
Synchronization coordinates concurrent execution so dependent operations observe completed memory writes in the required order.
- How it is used
- Coordinates threads during reductions so consumers do not read partial results before producers finish writing.
- How deep it goes
- Maps synchronization needs across warp, block, and grid scopes, but does not detail Triton synchronization constructs.
- Examples
- Uses reductions for gradient sums, softmax denominators, and normalization statistics as motivating workloads.
- What you can do after
- Understand when reductions require synchronization and which GPU communication scope supports their cooperating threads.
Read how GPU Programming with Triton explains synchronization →
Also covered in
- Clojure: The Essential Reference
- Functional Programming in C#, Second Edition
- Object-Oriented Software Design in C++
- Learn Concurrent Programming with Go
- Graph Neural Networks in Action
- CUDA for LLMs
- F# in Action: A Revised Edition of Get Programming with F#
- Code Like a Pro in Rust
What to know first
- threadA thread is a distinct sequence of execution with its own control flow and state, managed or scheduled by a processor, runtime, or operating system.
- CPUA central processing unit (CPU) is a computer processor that executes program instructions and performs general-purpose computational operations.
- race conditionA race condition is a concurrency defect in which program behavior or results depend on the timing or ordering of interacting operations.
- shared memoryShared memory is a memory region accessible to multiple processes, threads, or other concurrent execution contexts for sharing data.
Related concepts
- cudaDeviceSynchronizeimplemented by · cudaDeviceSynchronize is a CUDA Runtime API function that blocks the host until previously issued work on the device has completed.
- channelproduced by · A channel is a medium or logical pathway for conveying information, messages, or other content between sources and recipients.
- race conditionaddresses · A race condition is a concurrency defect in which program behavior or results depend on the timing or ordering of interacting operations.
- lockingincludes · Locking is a synchronization technique that controls concurrent access to a shared resource or protected operation.
- atomicityincludes · Atomicity is the property that an operation or group of operations takes effect as an indivisible whole, without observable partial effects.
Questions about synchronization
What is synchronization?
Synchronization is the coordination of concurrent activities, events, or system states to establish required ordering, alignment, access, or consistency relationships.
Which Manning books explain synchronization?
Grokking Concurrency, Modern C, Third Edition, 100 Go Mistakes and How to Avoid Them, Troubleshooting Java, Second Edition, Latency, Go in Action, Second Edition, C# Concurrency: Asynchronous and multithreaded programming, Grokking GPU Programming and 5 more.
What should I know before learning synchronization?
Manning books that teach synchronization usually introduce thread, CPU, race condition and shared memory first.
What kinds of synchronization are there?
Kinds of synchronization include leader-follower synchronization, locking and atomicity.
What is synchronization also called?
Synchronization is also called synchronize or synchronizing.
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.












