●推薦序一
推薦序二
推薦序三
推薦序四
前言
第1章 JMH
1.1 JMH簡介
1.2 JMH快速入門
1.2.1 用main方法進行測試
1.2.2 用JMH進行微基準測試
1.3 JMH的基本用法
1.3.1 @Benchmark標記基準測試方法
1.3.2 Warmup以及Measurement
1.3.3 四 enchmarkMode
1.3.4 OutputTimeUnit
1.3.5 三大State的使用
1.3.6 @Param的妙用
1.3.7 JMH的測試套件(Fixture)
1.3.8 CompilerControl
1.4 編寫正確的微基準測試以及高級用法
1.4.1 編寫正確的微基準測試用例
1.4.2 一些高級的用法
1.5 JMH的Profiler
1.5.1 StackProfiler
1.5.2 GcProfiler
1.5.3 ClassLoaderProfiler
1.5.4 CompilerProfiler
1.6 本章總結
第2章 Java並發包之原子類型詳解
2.1 AtomicInteger詳解
2.1.1 性能測試對比
2.1.2 AtomicInteger的基本用法
2.1.3 AtomicInteger內幕
2.1.4 AtomicInteger總結
2.2 AtomicBoolean詳解
2.2.1 AtomicBoolean的基本用法
2.2.2 AtomicBoolean內幕
2.2.3 Try Lock顯式鎖的實現
2.2.4 AtomicBoolean總結
2.3 AtomicLong詳解
2.4 AtomicReference詳解
2.4.1 AtomicReference的應用場景
2.4.2 AtomicReference的基本用法
2.4.3 AtomicReference的內幕
2.4.4 AtomicReference總結
2.5 AtomicStampedReference詳解
2.5.1 CAS算法ABA問題
2.5.2 AtomicStampedReference詳解
2.5.3 AtomicStampedReference總結
2.6 AtomicArray詳解
2.7 AtomicFieldUpdater詳解
2.7.1 原子性更新對像屬性
2.7.2 注意事項
2.7.3 AtomicFieldUpdater總結
2.8 sun.misc.Unsafe詳解
2.8.1 如何獲取Unsafe
2.8.2 JNI、Java和C/C++混合編程
2.8.3 危險的Unsafe
2.8.4 sun.misc.Unsafe總結
2.9 本章總結
第3章 Java並發包之工具類詳解
3.1 CountDownLatch工具詳解
3.1.1 等待所有子任務結束
3.1.2 CountDownLatch的其他方法及總結
3.2 CyclicBarrier工具詳解
3.2.1 等待所有子任務結束
3.2.2 CyclicBarrier的循環特性
3.2.3 CyclicBarrier的其他方法以及總結
3.2.4 CyclicBarrier VS. CountDownLatch
3.3 Exchanger工具詳解
3.3.1 一對線程間的數據交換
3.3.2 Exchanger的方法詳解
3.3.3 Exchanger總結
3.4 Semaphore工具詳解
3.4.1 Semaphore同時在線的用戶數量
3.4.2 使用Semaphore定義try lock
3.4.3 Semaphore其他方法詳解
3.4.4 擴展Semaphore增強release
3.4.5 Semaphore總結
3.5 Phaser工具詳解
3.5.1 Phaser的基本用法
3.5.2 Phase(階段)以及Phaser方法詳解
3.5.3 Phaser層級關繫
3.5.4 Phaser總結
3.6 Lock&ReentrantLock詳解
3.6.1 Lock及ReentrantLock方法詳解
3.6.2 正確使用顯式鎖Lock
3.6.3 ReentrantLock VS. Synchronized關鍵字
3.6.4 顯式鎖Lock總結
3.7 ReadWriteLock&ReentrantReadWriteLock詳解
3.7.1 讀寫鎖的基本使用方法
3.7.2 讀寫鎖的方法
3.7.3 基準測試性能對比
3.7.4 讀寫鎖總結
3.8 Condition詳解
3.8.1 初識Condition
3.8.2 Condition接口方法詳解
3.8.3 使用Condition之生產者消費者
3.8.4 Condition總結
3.9 StampedLock詳解
3.9.1 讀寫鎖的饑餓寫問題
3.9.2 StampedLock的使用
3.9.3 與其他鎖的性能對比
3.9.4 StampedLock總結
3.10 Guava之Monitor詳解
3.10.1 Monitor及Guard
3.10.2 Monitor的其他方法
3.10.3 Monitor總結
3.11 Guava之RateLimiter詳解
3.11.1 RateLimiter的基本使用
3.11.2 RateLimiter的限流操作——漏桶算法
3.11.3 令牌環桶算法
3.11.4 RateLimiter總結
3.12 本章總結
第4章 Java並發包之並發容器詳解
4.1 鏈表
4.1.1 基本的鏈表
4.1.2 優先級鏈表
4.1.3 跳表(SkipList)
4.1.4 鏈表總結
4.2 BlockingQueue(阻塞隊列)
4.2.1 ArrayBlockingQueue
4.2.2 PriorityBlockingQueue
4.2.3 LinkedBlockingQueue
4.2.4 DelayQueue
4.2.5 SynchronousQueue
4.2.6 LinkedBlockingDeque
4.2.7 LinkedTransferQueue
4.2.8 BlockingQueue總結
4.3 ConcurrentQueue(並發隊列)
4.3.1 並發隊列的性能
4.3.2 並發隊列在使用中需要注意的問題
4.3.3 並發隊列總結
4.4 ConcurrentMap(並發映射)
4.4.1 ConcurrentHashMap簡介
4.4.2 ConcurrentSkipListMap簡介
4.4.3 並發映射總結
4.5 寫時拷貝算法(Copy On Write)
4.5.1 CopyOnWrite讀實現操作分析
4.5.2 CopyOnWrite寫實現操作分析
4.5.3 CopyOnWrite總結
4.6 高並發無鎖(Lock Free)數據結構的實現
4.6.1 高並發無鎖鏈表的實現
4.6.2 Lock Free數據結構的測試
4.6.3 本節總結
4.7 本章總結
第5章 Java並發包之ExecutorService詳解
5.1 Executor&ExecutorService詳解
5.1.1 ThreadPoolExecutor詳解
5.1.2 ScheduledExecutorService詳解
5.1.3 關閉ExecutorService
5.1.4 Executors詳解
5.1.5 ExecutorService總結
5.2 Future和Callback
5.2.1 Future詳解
5.2.2 ExecutorService與Future
5.2.3 Future的不足之處
5.2.4 Google Guava的Future
5.2.5 Future總結
5.3 ForkJoinPool詳解
5.3.1 Fork/Join Framework介紹
5.3.2 ForkJoinTask詳解
5.3.3 ForkJoinPool總結
5.4 CompletionService詳解
5.4.1 ExecutorService執行批量任務的缺陷
5.4.2 CompletionService詳解
5.4.3 CompletionService總結
5.5 CompletableFuture詳解
5.5.1 CompletableFuture的基本用法
5.5.2 任務的異步運行
5.5.3 異步任務鏈
5.5.4 合並多個Future
5.5.5 多Future的並行計算
5.5.6 錯誤處理
5.5.7 JDK 9對CompletableFuture的進一步支持
5.5.8 CompletableFuture總結
5.6 本章總結
第6章 Java Streams詳解
6.1 Stream介紹及其基本操作
6.1.1 如何創建Stream
6.1.2 Stream之Intermediate操作
6.1.3 Stream之Terminal操作
6.1.4 NumericStream詳解
6.1.5 Stream總結
6.2 Collector在Stream中的使用
6.2.1 初識Collector
6.2.2 Collectors用法詳解
6.2.3 自定義Collector
6.2.4 Collector總結
6.3 Parallel Stream詳解
6.3.1 並行流Parallel Stream
6.3.2 Spliterator 詳解
6.3.3 Spliterator總結
6.4 本章總結
第7章 Metrics(Powerful Toolkit For Measure)
7.1 Metrics快速入門
7.1.1 如何監控度量應用程序
7.1.2 Metrics環境搭建
7.2 五大Metric詳解
7.2.1 Meter
7.2.2 Gauge
7.2.3 Counter
7.2.4 Histogram
7.2.5 Timer
7.3 Reporter詳解
7.3.1 ConsoleReporter
7.3.2 LogReporter
7.3.3 JMXReporter
7.3.4 CsvReporter
7.4 Metrics Plugins
7.4.1 Health Check
7.4.2 JVM Instrumentation
7.5 深入Metrics源碼
7.5.1 MetricRegistry如何工作
7.5.2 Reporter如何工作
7.5.3 拾遺補漏
7.6 本章總結
本書由淺入深、循序漸進地介紹Java高並發核心庫的精髓,幫助讀者掌握相關內容的技術細節。
內容講解以真實問題為導向,層層遞進,環環緊扣,詳細闡述每一個解決方案的來龍去脈。
通過大量的實際案例,原理剖析和實戰代碼相結合,讓讀者能夠更加清晰深入地理解每一個技術細節的用法和實用技巧。
詳細介紹Java微基準測試工具集JMH與平臺級性能指標數據度量工具Metrics的使用方法,幫助讀者快速開發出高效、健壯的並發應用程序。
本書共包含四大部分。
第①部分(第1章)詳細介紹了JMH微基準測試工具的使用細節。該工具是由Oracle JVM開發團隊相關成員開發的,開發者借助它能夠了解自己編寫的程序代碼以及程序在運行期的準確性能表現。在本書的其他章節對API之間的性能進行對比時,主要也是依賴該工具,因此在學習本書的其他章節時,優選能夠掌握該部分內容等