The Art of Java Concurrency Programming
Tags
Summary
The book begins by asking "what exactly makes concurrency so hard," first discussing the three core challenges of concurrent programming: context switching, deadlock, and resource limits. It then analyzes the underlying implementation principles of volatile, synchronized, and atomic operations from both the CPU and JVM levels. After that, it devotes considerable space to a systematic explanation of the Java Memory Model: reordering and sequential consistency, the happens-before rules, the memory semantics of volatile and locks, the semantics of final fields, and the correct implementation of double-checked locking and lazy initialization.
At the foundational and tooling levels, the book explains the thread lifecycle, starting and terminating threads, the interruption mechanism, the classic wait/notify paradigm, ThreadLocal, and other means of inter-thread communication. It then breaks down the Java concurrency package layer by layer: the Lock interface and the AQS queue synchronizer, reentrant locks and read-write locks, Condition, concurrent containers such as ConcurrentHashMap and ConcurrentLinkedQueue, the Fork/Join framework, atomic operation classes, concurrency utilities such as CountDownLatch, CyclicBarrier, Semaphore, and Exchanger, and the implementation principles and configuration recommendations of thread pools and the Executor framework. It concludes with practical content including the producer-consumer pattern, online problem diagnosis, performance testing, and asynchronous task pools.
Concise in length and focused on principles and source code analysis, the book includes abundant example code and is suitable for systematic study by Java developers who wish to move from "knowing how to use concurrency APIs" to "understanding why concurrency is designed the way it is."
Editor's review
Who it's for
A good fit for
- 有 1–3 年 Java 开发经验、想系统理解并发原理的后端工程师。
- 准备中高级 Java 岗位面试,需要梳理 JMM、AQS、线程池等考点的求职者。
- 习惯通过阅读 JDK 源码提升设计能力的技术人员。
- 计算机专业高年级学生或研究生,把并发编程作为课程延伸阅读。
Not a good fit for
- 完全没有 Java 基础、尚未掌握集合与泛型语法的初学者。
- 只想查阅 API 用法速查表的读者,本书更偏原理而非手册。
- 希望深入分布式一致性、消息中间件等系统级并发问题的读者。
Reading tips
- 按章节顺序通读,第 3 章内存模型建议反复读,先建立 happens-before 直觉再读后续并发包源码。
- 边读边打开 JDK 源码对照,重点跟踪 AQS 的独占/共享获取流程与线程池的 worker 执行路径。
- 动手复现书中的上下文切换、死锁与双重检查锁定示例,用 jstack、JFR 等工具观察实际行为。
- 关注版本差异:书中基于较早期 JDK,建议结合当前 JDK 文档确认 ConcurrentHashMap、FutureTask 等实现的演变。
About the publisher
In addition to science and technology and professional publishing, the books in our catalog from China Machine Press also reflect a sustained focus on psychology, computing, management, finance and economics, and social sciences. In psychology, the catalog includes works by C. G. Jung and introductions to analytical psychology, as well as applied topics such as stress and health, and addiction and healing. In computing, it features Structure and Interpretation of Computer Programs (JavaScript Edition). Management and finance titles include Administrative Behavior (4th Edition), The Price of Inequality (Collector's Edition), and This Time Is Different: Eight Centuries of Financial Folly (Commemorative Edition). In the philosophy and history of science, there is The Worldview: The Third Edition. Relevant authors include C. G. Jung, William McGuire, Sonu Shamdasani, and Gabor Maté. Public information is limited; the above summarizes the publisher's profile based solely on the books in our catalog.
Contents
- Preface
- Chapter 1 The Challenges of Concurrency Programming
- 1.1 Context Switching
- 1.1.1 Is Multithreading Always Faster?
- 1.1.2 Measuring the Number and Duration of Context Switches
- 1.1.3 How to Reduce Context Switching
- 1.1.4 Reducing Context Switching in Practice
- 1.2 Deadlock
- 1.3 The Challenge of Resource Limits
- 1.4 Chapter Summary
- Chapter 2 The Underlying Implementation Principles of Java's Concurrency Mechanisms
- 2.1 Applications of volatile
- 2.2 Implementation Principles and Applications of synchronized
- 2.2.1 Java Object Headers
- 2.2.2 Lock Escalation and Comparison
- 2.3 Implementation Principles of Atomic Operations
- 2.4 Chapter Summary
- Chapter 3 The Java Memory Model
- 3.1 Fundamentals of the Java Memory Model
- 3.1.1 Two Key Questions of Concurrency Programming Models
- 3.1.2 The Abstract Structure of the Java Memory Model
- 3.1.3 Reordering from Source Code to Instruction Sequence
- 3.1.4 Classification of Concurrency Programming Models
- 3.1.5 Introduction to happens-before
- 3.2 Reordering
- 3.2.1 Data Dependence
- 3.2.2 as-if-serial Semantics
- 3.2.3 Program Order Rule
- 3.2.4 The Impact of Reordering on Multithreading
- 3.3 Sequential Consistency
- 3.3.1 Data Races and Sequential Consistency
- 3.3.2 The Sequentially Consistent Memory Model
- 3.3.3 The Sequential Consistency Effect of Synchronized Programs
- 3.3.4 Execution Characteristics of Unsynchronized Programs
- 3.4 The Memory Semantics of volatile
- 3.4.1 Characteristics of volatile
- 3.4.2 The happens-before Relationship Established by volatile Write-Read
- 3.4.3 The Memory Semantics of volatile Write-Read
- 3.4.4 Implementation of volatile Memory Semantics
- 3.4.5 Why JSR-133 Strengthened the Memory Semantics of volatile
FAQ
这本书适合零基础学 Java 的人读吗?
这本书和《Java并发编程实战》有什么区别?
书中的内容和现在的 JDK 版本还匹配吗?
三个作者合著会不会内容割裂?
有必要买第 2 版吗?
Comments
Find this book
This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.
About the author
Information about Wei Peng currently available to the public is limited, and details such as his nationality, dates of birth and death, and educational background cannot be confirmed. Judging from the works held in the collection, he participated in writing two biographical books, Liu Hulan and Huang Jiguang, both of which focus on heroic figures in Chinese revolutionary history. Works of this kind typically recount a person's life and deeds in an accessible, documentary style, emphasizing the clear presentation of historical facts and the expression of spiritual meaning. They are aimed at general readers, especially young people, and serve the functions of historical education and the transmission of values. Both books are classified under general biography, indicating that his writing leans toward popular works of documented lives. Overall, Wei Peng's work centers on biographies of heroic figures, with a plain style and clear narrative, and carries certain significance for spreading stories of figures from revolutionary history. Because verifiable material is quite limited, any assessment of his writing career and overall achievements awaits further information.
Cheng Xiaoming is an author about whom little public information is available. The only work currently on record is A Pharmacoeconomic Evaluation Study of Tongmai Yangxin Pills, commonly classified under finance and economics. The title indicates that the author's writing focuses on pharmacoeconomic evaluation, offering an economic analysis of a specific traditional Chinese medicine product and touching on intersecting issues such as medical costs, therapeutic efficacy, and resource utilization. Such subject matter requires knowledge of both medicine and economics, and the writing tends toward data-supported, empirical analysis in a rigorous and pragmatic style. Because only this one work is held in the collection, nothing can be confirmed about the author's nationality, dates of birth and death, educational background, or professional positions, and no speculation is offered. On the available evidence, Cheng Xiaoming writes in the specialized field of pharmacoeconomic evaluation, addressing practitioners and researchers in public health, health economics, and policy studies, and the work offers a useful analytical framework for economic assessment of the product concerned.