没有合适的资源?快使用搜索试试~ 我知道了~
首页Java Concurrency in Practice 无水印pdf
Java Concurrency in Practice 无水印pdf
4星 · 超过85%的资源 需积分: 50 138 下载量 55 浏览量
更新于2023-03-16
评论 4
收藏 3.88MB PDF 举报
Java Concurrency in Practice 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
资源详情
资源评论
资源推荐
JavaConcurrency
InPractice
BrianGöetz
TimPeierls
JoshuaBloch
JosephBowbeer
DavidHolmes
DougLea
Addison‐WesleyProfessional
ISBN‐10:0‐321‐34960‐1
ISBN‐13:978‐0‐321‐34960‐6
ii
JavaConcurrencyInPractice
Index
Index ii
Preface xiii
HowtoUsethisBook
xiii
CodeExam
ples xiv
Acknowledgments
xv
Chapter 1 - Introduction 1
1.1. A (Very) Brief History of Concurrency 2
1.2. Benefits of Threads 3
1.2.1.Exploi
tingMultipleProcessors 3
1.2.2.SimplicityofMod
eling 3
1.2.3.Simplifi
edHandlingofAsynchronousEvents 3
1.2.4.MoreRespon
siveUserInterfaces 4
1.3. Risks of Threads 5
1.3.1.SafetyHazard
s 5
1.3.2.LivenessHa
zards 6
1.3.3.Perfor
manceHazards 6
1.4. Threads are Everywhere 8
Part I: Fundamentals 10
Chapter 2. Thread Safety 11
2.1.WhatisThre
adSafety? 12
2.2.Atomi
city 13
2.3.Locking
16
2.4.Guardin
gStatewithLocks 19
2.5.LivenessandPerformance
20
Chapter 3. Sharing Objects 23
3.1.Visi
bility 23
3.2.Public
ationandEscape 26
3.3.Thr
eadConfinement 28
3.4.Immutability
31
3.5.SafePubl
ication 33
Chapter 4. Composing Objects 37
4.1.Designin
gaThread‐safeClass 37
4.2.In
stanceConfinement 39
4.3.Del
egatingThreadSafety 41
4.4.AddingF
unctionalitytoExistingThread‐safeClasses 47
4.5.Docum
entingSynchronizationPolicies 49
Chapter 5. Building Blocks 51
5.1.Sync
hronizedCollections 51
5.2.Concurr
entCollections 54
5.3.BlockingQueuesan
dtheProducer‐consumerPattern 56
5.4.BlockingandInterruptibleMethods
59
5.5.Sync
hronizers 60
5.6.Buildi
nganEfficient,ScalableResultCache 64
SummaryofPartI
69
iii<Index
Part II: Structuring Concurrent Applications 71
Chapter 6. Task Execution 72
6.1.Execut
ingTasksinThreads 72
6.2.Th
eExecutorFramework 74
6.3.FindingExploitableParallelism
78
Summary
83
Chapter 7. Cancellation and Shutdown 85
7.1.Ta
skCancellation 85
7.2.Stop
pingaThread‐basedService 93
7.3.HandlingAbnormalTh
readTermination 100
7.4.JV
MShutdown 102
Summary
103
Chapter 8. Applying Thread Pools 104
8.1.Impli
citCouplingsBetweenTasksandExecutionPolicies 104
8.2.SizingTh
readPools 105
8.3.Configuri
ngThreadPoolExecutor 106
8.4.Extendi
ngThreadPoolExecutor 111
8.5.Parall
elizingRecursiveAlgorithms 112
Summary
116
Chapter 9. GUI Applications 117
9.1.WhyareGUI
sSingle‐threaded? 117
9.2.Short‐r
unningGUITasks 119
9.3.Long‐runningGU
ITasks 121
9.4.Shar
edDataModels 123
9.5.OtherFo
rmsofSingle‐threadedSubsystems 125
Summary
126
Part III: Liveness, Performance, and Testing 127
Chapter 10. Avoiding Liveness Hazards 128
10.1.Deadlock
128
10.2.AvoidingandDiag
nosingDeadlocks 133
10.3.OtherLi
venessHazards 135
Summary
136
Chapter 11. Performance and Scalability 137
11.1.Thi
nkingaboutPerformance 137
11.2.Amda
hl'sLaw 139
11.3.CostsI
ntroducedbyThreads 142
11.4.Re
ducingLockContention 144
11.5.Exampl
e:ComparingMapPerfor mance 150
11.6.Re
ducingContextSwitchOverhead 151
Summary
152
Chapter 12. Testing Concurrent Programs 153
12.1.Te
stingforCorrectness 153
12.2.Te
stingforPerformance 160
12.3.AvoidingPerformanc
eTestingPitfalls 165
12.4.ComplementaryTe
stingApproaches 167
Summary
169
Part IV: Advanced Topics 170
Chapter 13 - Explicit Locks 171
13.1.Lockan
dReentrantLock 171
13.2.Perform
anceConsiderations 174
13.3.Fairn
ess 175
iv
JavaConcurrencyInPractice
13.4.ChoosingBetweenSy
nchronizedandReentrantLock 176
13.5.Re
ad‐writeLocks 176
Summary
178
Chapter 14 - Building Custom Synchronizers 179
14.1.Mana
gingStateDependence 179
14.2.UsingC
onditionQueues 183
14.3.Explici
tConditionObjects 188
14.4.Anatom
yofaSynchronizer 189
14.5.Abs
tractQueuedSynchronizer 190
14.6.AQSinJava.util
.concurrentSynchronizerClasses 192
Summary
194
Chapter 15. Atomic Variables and Non-blocking Synchronization 195
15.1.Dis
advantagesofLocking 195
15.2.HardwareSupp
ortforConcurrency 196
15.3.AtomicVariableClasses
198
15.4.Non‐blo
ckingAlgorithms 201
Summary
206
Chapter 16. The Java Memory Model 207
16.1.WhatisaMemoryModel,an
dWhywouldIWantOne? 207
16.2.Publication
211
Summary
215
Appendix A. Annotations for Concurrency 216
A.1.ClassA
nnotations 216
A.2.Fi
eldandMethodAnnotations 216
Bibliography 217
v1BListingandImageIndex
ListingandImageIndex
Preface v
Listing1.BadWaytoSortaList.Don'tDothis.
xiv
Listing2.LessthanOp
timalWaytoSortaList. xv
Chapter 1. Introduction 11
Listing1.
1.Non‐thread‐safeSequenceGenerator. 5
Figure1.
1.UnluckyExecutionofUnsafeSequence.Nextvalue. 5
Listing1.
2.Thread‐safeSequenceGenerator. 6
Chapter 2. Thread Safety 11
Listing2.
1.AStatelessServlet. 13
Listing2.
2.ServletthatCountsRequestswithouttheNecessarySynchronization. Don'tDothis. 14
Listing2.
3.RaceConditioninLazyInitialization.Don'tDothis. 15
Listing2.
4.ServletthatCountsRequestsUsingAtomicLong. 16
Listing2.
5.ServletthatAttemptstoCacheitsLastResultwithoutAdequateAtomicity.Don'tDothis. 17
Listing2.
6.ServletthatCachesLastResult,ButwithUnacceptablyPoorConcurrency.Don'tDothis. 18
Listing2.
7.CodethatwouldDeadlockifIntrinsicLockswereNotReentrant. 18
Figure2.
1.PoorConcurrencyofSynchronizedFactorizer. 21
Listing2.
8.ServletthatCachesitsLastRequestandResult. 21
Chapter 3. Sharing Objects 23
Listing3.
1.SharingVariableswithoutSynchronization.Don'tDothis. 23
Listing3.
2.Non‐thread‐safeMutableIntegerHolder. 24
Listing3.
3.Thread‐safeMutableIntegerHolder. 24
Figure3.
1.VisibilityGuaranteesforSynchronization. 25
Listing3.
4.CountingSheep. 26
Listing3.
5.PublishinganObject. 27
Listing3.
6.AllowingInternalMutableStatetoEscape.Don'tDothis. 27
Listing3.
7.ImplicitlyAllowingthethisReferencetoEscape.Don'tDothis. 28
Listing3.
8.UsingaFactoryMethodtoPreventthethisReferencefromEscapingDuringConstruction. 28
Listing3.
9.ThreadConfinementofLocalPrimitiveandReferenceVariables. 30
Listing3
.10.UsingThreadLocaltoEnsurethreadConfinement. 30
Listing3
.11.ImmutableClassBuiltOutofMutableUnderlyingObjects. 32
Listing3
.12.ImmutableHolderforCachingaNumberanditsFactors. 33
Listing3
.13.CachingtheLastResultUsingaVolatileReferencetoanImmutableHolderObject. 33
Listing3
.14.PublishinganObjectwitho utAdequateSynchronization.Don'tDothis. 33
剩余233页未读,继续阅读
yinkaisheng-nj
- 粉丝: 763
- 资源: 6953
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
- MW全能培训汽轮机调节保安系统PPT教学课件.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论3