Key Takeaways
Treat concurrency as a tool for responsiveness, resilience, and scale, not only speed
Two different problems. Concurrency means organizing a program to handle multiple activities; parallelism means doing multiple computations at the same time to finish faster. A teacher switching between students handles concurrent demands, while two teachers helping separate students work in parallel. The distinction matters because concurrency can improve responsiveness even on one core, while parallelism can accelerate a task without introducing competing state.
What's striking is how this distinction changes the first question a programmer asks. Instead of starting with, “How many threads can this use?”, the design can begin with the problem's shape: Are independent requests arriving, or is one large calculation divisible? That resembles a broader engineering principle: match a system's structure to the behavior it must handle. The caveat is that concurrency can improve responsiveness while adding coordination costs, so it is not automatically simpler or faster.
Replace ad hoc locks with ownership, ordering, and tested concurrency utilities
Three quiet hazards. Threads sharing mutable memory can lose updates, see stale values, or deadlock. In the book's counter example, two threads each increment a number 10,000 times, but unsynchronized updates produce inconsistent totals. Even publishing a flag before its associated value is safe only when synchronization makes both writes visible in the intended order. The dining-philosophers example shows deadlock: each person holds one chopstick while waiting for another. A global lock order prevents this cycle; calling unknown callbacks while holding a lock can reintroduce it.
The chapter's most sobering point is that a bug-free test run is weak evidence of thread safety. Some failures depend on rare timing or hardware behavior, so the defect can survive for months and appear after an upgrade. This is why mature concurrency libraries matter: they package difficult synchronization decisions into tested queues, atomic variables, and thread pools. Still, abstractions do not abolish resource limits. A pool with an unbounded queue, for example, can merely defer overload until memory becomes the failure point.
Make independent computations pure before trying to run them in parallel
Remove shared writes. Functional programming expresses work as evaluations of functions rather than a series of changes to shared variables. A pure function returns the same result for the same inputs and causes no outside effects, so independent calls can run in any order without racing over shared state. The book contrasts this with Java's `SimpleDateFormat`, which hides mutable internals despite appearing constant from the outside.
What's powerful here is that parallelism becomes a consequence of clean decomposition, not a separate layer of locking. This connects to the idea of referential transparency in mathematics: replacing a calculation with its result does not alter the program's meaning. But the guarantee depends on actual purity. Floating-point addition, for instance, can produce tiny rounding differences when grouped differently, and network calls or logging are effects that cannot be casually reordered. Purity makes parallel reasoning easier, not magically cost-free.
Keep changing state behind atomic identities and persistent values
Separate name from value. Clojure's persistent data structures preserve old versions when an update creates a new one. A request handler that has read one version can safely finish using it even if another handler updates the current value. An atom provides a synchronous, atomic change to one value; an agent queues asynchronous changes to one value; refs allow coordinated changes to several values inside a transaction. A bank transfer, for example, must debit one account and credit another together.
This design resembles multi-version concurrency control in databases: readers can work from a stable snapshot while writers publish a newer state. It also makes state changes easier to inspect and test because an update produces a new value rather than mutating an object under every reader. There are trade-offs. Atom updates may retry when writers collide, so update functions must avoid side effects; STM can also retry conflicting transactions. The model reduces hazards, but contention still has a price.
Build distributed services from isolated actors with explicit failure supervision
One process, one state. An actor owns its state and processes incoming messages one at a time from a mailbox. Other actors cannot reach in and change that state directly. In Elixir, linked processes can report failures, and supervisors can restart workers. This supports a small, clear failure-handling core while ordinary workers focus on their normal tasks. In the distributed word-count example, page identifiers let the accumulator reject duplicate results when a failed worker's page is assigned again.
Actors apply the logic of fault isolation: a failed component should be replaceable without bringing down its neighbors. This is closely related to the bulkhead principle in resilient systems, where independent compartments limit how far failures spread. The model's discipline is also a constraint: messages can be lost around failures, worker state may disappear on restart, and mailboxes can grow without bound. Supervision is strongest when paired with explicit retry, timeout, and state-recovery decisions.
Model asynchronous workflows as channels, with backpressure instead of callback webs
Make communication independent. Communicating Sequential Processes, or CSP, emphasizes channels rather than actors' built-in mailboxes. A channel can be created, passed around, read, or written by separate tasks. In Clojure's core.async, go blocks let tasks park while waiting for channel operations, freeing their threads for other work. The book's RSS reader connects feed polling, article retrieval, and word counting in a readable pipeline. Unbuffered channels naturally make a writer wait for a reader; bounded buffers offer other explicit overflow policies.
Channels make the route of information visible, a useful complement to actors' focus on who owns behavior. This has particular value in event-heavy software, where callback chains can hide control flow and scatter state across handlers. The buffer choices also expose a central queueing question: when producers outrun consumers, should the system wait, discard old values, or discard new ones? No option is universally correct. The right policy depends on whether preserving every event or staying current matters more.
Send uniform number crunching to GPUs only when data stays nearby
Many small jobs. A GPU excels when the same operation can be applied independently to many numerical values. In OpenCL, a kernel describes the work for one work-item, while the runtime schedules many work-items across the device. The book reports over 20 times faster execution for one matrix-multiplication example, and about 13 times faster after including data transfers. By contrast, transferring arrays for a simple multiplication can cost more than the computation itself.
The example captures a recurring systems lesson: peak compute speed is irrelevant if moving data dominates the job. GPU programming works best when a workload has abundant parallelism and data can remain on the device across multiple operations. This is why image processing and simulation are natural fits, while irregular, branch-heavy tasks can be harder to map efficiently. The reported speedups are useful demonstrations, not promises; device architecture, transfer overhead, and workload shape determine the real result.
Preserve raw events, recompute batch views, and patch freshness with streams
Keep history authoritative. The Lambda Architecture treats immutable raw events as the lasting record and calculates useful views from them. Its batch layer uses MapReduce across a cluster to build those views, making large historical datasets practical to process and allowing results to be rebuilt after software errors. Because batch jobs have latency, a speed layer processes recent events as they arrive. Queries combine the historical view with this newer stream-derived view. In Storm, processing may happen at least once, so operations such as adding timestamps to a set help prevent duplicate effects.
The architecture is compelling because it treats derived data as disposable and raw history as the source of truth. That makes correction and auditability part of the design rather than emergency procedures. The cost is duplication: separate batch and streaming paths must agree on what an event means, and their results must be combined without gaps or double counting. This architecture earns its complexity when data volume and historical analysis justify it. For smaller systems, the machinery can outweigh the benefit.
Choose the model by the shape of the problem, not fashion
Use the right tool. The book's seven models occupy different territory. Threads and locks are broadly available but difficult to reason about. Functional programming makes independent calculations easier to parallelize. Clojure adds safe ways to manage changing state. Actors emphasize isolated behavior, supervision, and distribution; CSP emphasizes flexible communication channels. GPUs suit regular numerical work. MapReduce and the Lambda Architecture address very large historical datasets and timely updates. None is a universal replacement for sequential code.
The survey's enduring contribution is a change in vocabulary. A developer can distinguish a timing-sensitive concurrent problem from a deterministic parallel calculation, then choose whether the main challenge is shared state, failure, communication, numerical throughput, or data volume. This is more useful than treating concurrency as a single advanced feature. A practical selection should also account for operational maturity, team experience, and observability. A theoretically elegant model can be a poor choice if the surrounding tools cannot be deployed and debugged well.
Analysis
The book is best read as a map of design trade-offs, not a contest in which one concurrency model wins. Its narrative begins with the familiar but hazardous threads-and-locks approach, then moves through ways of changing the problem: eliminate shared mutation, constrain it with concurrency-aware references, isolate it inside actors, or make communication explicit through channels. It then widens the scale, from GPU work-items to cluster-level batch and streaming systems. The progression makes a strong argument that concurrency is not merely a performance technique. It is also a way to represent responsiveness, failure boundaries, and the structure of real-world work.
The deepest through-line is controlled ownership of change. Functional code avoids change; persistent values preserve safe snapshots; actors confine change to one process; channels make transfers visible; immutable event logs make large-scale recomputation possible. These are variations on one architectural instinct: reduce the number of places where a changing value can be observed or altered. That instinct is more durable than the specific libraries surveyed.
The examples also reveal the limits of slogan-level advice. Immutability does not eliminate all costs, actors do not automatically prevent deadlock or mailbox overload, and a GPU can lose its advantage to data movement. Even a correct parallel algorithm may scale poorly when shared updates dominate, as the word-count benchmark demonstrates. Performance must be measured on the real workload, while correctness needs reasoning that ordinary stress tests cannot supply.
Because the book appeared in 2014, some named tools and APIs are historical snapshots. The more lasting value lies in the questions it teaches readers to ask: Is the problem concurrent, parallel, or both? What state is shared? Where does communication occur? What happens when a component fails? How much data must move? Those questions remain useful even when implementations change.
Review Summary
Seven Concurrency Models in Seven Weeks receives mixed reviews, with an average rating of 3.82/5. Readers appreciate its well-structured approach to different concurrency models and languages. Many find it informative for expanding their understanding of concurrent programming. However, some criticize the heavy focus on Clojure and the use of less common languages. The book's breadth is praised, but some find certain chapters too shallow or complex. Overall, it's recommended for those interested in exploring various concurrency paradigms, though prior programming knowledge is beneficial.
Glossary
Java memory model
Rules for cross-thread visibilityThe Java memory model specifies when writes made by one thread are guaranteed to be visible to another, and what ordering guarantees synchronization provides. Without appropriate synchronization on both sides of a shared-memory interaction, a thread may observe stale values or operations in an unexpected order.
Referential transparency
Replace calls with resultsAn expression is referentially transparent when replacing it with its result leaves program behavior unchanged. Pure functions have this property because their output depends only on their inputs and they cause no external side effects. Independent transparent computations can be reordered or evaluated in parallel without changing the intended result.
Persistent data structures
Preserve prior versionsPersistent data structures retain earlier versions when updated. They behave as if a copy were made, but typically share unchanged internal structure to avoid copying everything. A thread holding an older version continues to see a stable value even after another thread creates a newer version.
Atom
Synchronous single-value updatesIn Clojure, an atom is a concurrency-aware reference to one value. It supports atomic updates, commonly through a function that computes a replacement from the current value. Contending updates may be retried, so update functions and validators must not perform side effects.
Agent
Asynchronous single-value updatesA Clojure agent holds one value and processes submitted update functions asynchronously, in sequence. Sending an action returns before the update necessarily completes. Because an action is not retried in the same way as an atom update, it can be useful for serialized side effects, though failures require explicit handling.
Software transactional memory
Coordinate updates without locksSoftware transactional memory, or STM, coordinates changes to multiple references as a transaction. In Clojure, transactions can read and update refs together, so observers see a consistent all-or-nothing result. Conflicting transactions may be retried, which means their bodies must avoid uncoordinated side effects.
Actor model
Isolate state behind messagesThe actor model structures a concurrent program as independent entities that own their state and communicate by asynchronous messages. Each actor processes its messages sequentially, avoiding direct shared-memory updates. Actor systems can use links and supervisors to detect failures and restart selected components.
Error-kernel pattern
Keep essential recovery logic smallThe error-kernel pattern keeps the code responsible for a system's correct operation as small and simple as possible. In actor systems, supervisors form a key part of this kernel: they monitor workers and decide when to start, stop, or restart them, while risky work remains isolated in subordinate processes.
Communicating Sequential Processes
Coordinate tasks through channelsCommunicating Sequential Processes, or CSP, is a model in which independent sequential tasks communicate through channels. Channels are separate from the tasks that use them, so producers and consumers need not know each other's identities. This differs from actors, whose communication is commonly centered on each actor's mailbox.
Go block
Park asynchronous code efficientlyIn Clojure's core.async, a go block transforms sequential-looking code into a state machine that can park while waiting for channel operations. Parking releases the thread for other tasks, allowing many concurrent workflows to share a smaller thread pool. Blocking operations inside a go block defeat this purpose.
Work-item
One instance of kernel workIn OpenCL, a work-item is one execution of a kernel for a particular position in a work range. Programmers commonly divide data-parallel problems into many small work-items, each handling a portion of the data. The runtime schedules these items on the device's available processing hardware.
MapReduce
Distribute map and reduce workMapReduce is both a programming pattern and, in Hadoop, a distributed processing system. Mappers turn input records into key-value pairs; the system groups values by key and sends each key's values to a reducer. Splitting work across machines enables large jobs and allows failed tasks to be retried.
Lambda Architecture
Combine historical and fresh viewsThe Lambda Architecture combines a batch layer, which rebuilds views from an immutable historical record, with a speed layer, which processes recent events with low latency. A serving layer combines their results for queries. The design trades added system complexity for scalable historical computation, fresh results, and the ability to regenerate derived views.
Download PDF
Download EPUB
.epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.