Java Concurrency in Practice
Tags
Summary
Editor's review
Who it's for
A good fit for
- 有 Java 基础、写过简单多线程代码,希望系统补齐并发知识体系的开发者
- 正在处理线上并发缺陷(数据错乱、偶发死锁、切换开销大)的后端工程师
- 需要设计线程安全类与基础组件、想理解 JDK 并发包设计取舍的架构师
- 讲授 Java 并发课程、需要权威参考框架的高校教师与培训讲师
Not a good fit for
- 完全没写过 Java、连语法与集合框架都不熟悉的零基础读者
- 只想复制粘贴代码、不愿意思考内存模型与设计原则的读者
- 主要使用 Go、Rust、C++ 等其他语言并寻求对应并发方案的读者
Reading tips
- 先通读第 2—5 章第一部分,把原子性、可见性、安全发布三个概念吃透,这是全书地基。
- 第二部分建议对照 JDK 源码与自己的项目阅读,读完每章就把 Executor、线程池配置用到实际代码里。
- 第 13—16 章属高级主题,可在遇到自定义同步器或排查内存可见性问题时再精读,不必强求一次读完。
- 书中示例代码可下载后亲手运行并故意制造竞态,再对照书中的修复方式,效果远好于只看不练。
About the publisher
The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.
Contents
- Code List
- Foreword
- Chapter 1 Introduction (1.1 A Brief History of Concurrency; 1.2 Benefits of Threads; 1.3 Risks of Threads; 1.4 Threads Are Everywhere)
- Part 1 Fundamentals
- Chapter 2 Thread Safety (2.1 What Is Thread Safety?; 2.2 Atomicity; 2.3 Locking; 2.4 Guarding State with Locks; 2.5 Liveness and Performance)
- Chapter 3 Sharing Objects (3.1 Visibility; 3.2 Publication and Escape; 3.3 Thread Confinement; 3.4 Immutability; 3.5 Safe Publication)
- Chapter 4 Composing Objects (4.1 Designing a Thread-Safe Class; 4.2 Instance Confinement; 4.3 Delegating Thread Safety; 4.4 Adding Functionality to Existing Thread-Safe Classes; 4.5 Documenting Synchronization Policies)
- Chapter 5 Building Blocks (5.1 Synchronized Collections; 5.2 Concurrent Collections; 5.3 Blocking Queues and the Producer–Consumer Pattern; 5.4 Blocking and Interruptible Methods; 5.5 Synchronizers; 5.6 Building an Efficient, Scalable Result Cache)
- Part 2 Structuring Concurrent Applications
- Chapter 6 Task Execution (6.1 Executing Tasks in Threads; 6.2 The Executor Framework; 6.3 Finding Exploitable Parallelism)
- Chapter 7 Cancellation and Shutdown (7.1 Task Cancellation; 7.2 Stopping a Thread-Based Service; 7.3 Handling Abnormal Thread Termination; 7.4 JVM Shutdown)
- Chapter 8 Applying Thread Pools (8.1 Implicit Couplings Between Tasks and Execution Policies; 8.2 Sizing Thread Pools; 8.3 Configuring ThreadPoolExecutor; 8.4 Extending ThreadPoolExecutor; 8.5 Parallelizing Recursive Algorithms)
- Chapter 9 GUI Applications (9.1 Why Are GUIs Single-Threaded?; 9.2 Short-Lived GUI Tasks; 9.3 Long-Lived GUI Tasks; 9.4 Shared Data Models; 9.5 Other Forms of Single-Threaded Subsystems)
- Part 3 Liveness, Performance, and Testing
- Chapter 10 Avoiding Liveness Hazards (10.1 Deadlock; 10.2 Avoiding and Diagnosing Deadlocks; 10.3 Other Liveness Hazards)
- Chapter 11 Performance and Scalability (11.1 Thinking About Performance; 11.2 Amdahl's Law; 11.3 Costs Introduced by Threads; 11.4 Reducing Lock Contention; 11.5 Example: Comparing Map Performance; 11.6 Reducing Context-Switch Overhead)
- Chapter 12 Testing Concurrent Programs (12.1 Testing for Correctness; 12.2 Testing for Performance; 12.3 Avoiding Performance Testing Pitfalls; 12.4 Supplemental Test Methods)
- Part 4 Advanced Topics
- Chapter 13 Explicit Locks (13.1 Lock and ReentrantLock; 13.2 Performance Considerations; 13.3 Fairness; 13.4 Choosing Between synchronized and ReentrantLock; 13.5 Read-Write Locks)
- Chapter 14 Building Custom Synchronizers (14.1 Managing State Dependence; 14.2 Using Condition Queues; 14.3 Explicit Condition Objects; 14.4 Anatomy of a Synchronizer; 14.5 AbstractQueuedSynchronizer; 14.6 AQS in java.util.concurrent)
- Chapter 15 Atomic Variables and Nonblocking Synchronization (15.1 Disadvantages of Locking; 15.2 Hardware Support for Concurrency; 15.3 Atomic Variable Classes; 15.4 Nonblocking Algorithms)
- Chapter 16 The Java Memory Model (16.1 What Is a Memory Model, and Why Do We Need It?; 16.2 Publication; 16.3 Initialization Safety)
- Appendix A Synchronization Annotations
- References
- Index
FAQ
《Java并发编程实践》和《Java并发编程实战》是同一本书吗?
这本书的六个作者是什么背景?
书中内容是否已经过时,还能读吗?
阅读前需要怎样的 Java 基础?
这本书有配套源码或练习吗?
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.