没有合适的资源?快使用搜索试试~ 我知道了~
java concurrenty in practice pdf
需积分: 9 10 下载量 180 浏览量
2012-12-04
21:45:39
上传
评论
收藏 5.01MB PDF 举报
温馨提示
试读
234页
java并发编程实践的英文版,比chm的要好很多,没有那么多错误的英文单词。
资源推荐
资源详情
资源评论
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.ServletthatCountsRequestswithouttheNecessarySynchroni zation.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.ImmutableHolderforCachingaNumberanditsFactor s. 33
Listing3
.13.CachingtheLastResultUsingaVolatileReferencetoanImmutableHolderObject. 33
Listing3
.14.PublishinganObjectwithoutAdequateSynchronization.Don'tDothis. 33
剩余233页未读,继续阅读
资源评论
njnu_zhoubo
- 粉丝: 7
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功