更新时间:2021-07-16 17:32:57
封面
Title Page
Copyright and Credits
Concurrent Patterns and Best Practices
Packt Upsell
Why subscribe?
packt.com
Contributors
About the authors
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
Concurrency – An Introduction
Concurrency in a breeze
The push for concurrency
The MapReduce pattern
Fault tolerance
Time sharing
Two models for concurrent programming
The message passing model
Coordination and communication
Flow control
Divide and conquer
The concept of state
The shared memory and shared state model
Threads interleaving – the need for synchronization
Race conditions and heisenbugs
Correct memory visibility and happens-before
Sharing blocking and fairness
Asynchronous versus synchronous executions
Java's nonblocking I/O
Of patterns and paradigms
Event-driven architecture
Reactive programming
The actor paradigm
Message brokers
Software transactional memory
Parallel collections
Summary
A Taste of Some Concurrency Patterns
A thread and its context
Race conditions
The monitor pattern
Thread safety correctness and invariants
Sequential consistency
Visibility and final fields
Double-checked locking
Safe publication
Initializing a demand holder pattern
Explicit locking
The hand-over-hand pattern
Observations – is it correct?
The producer/consumer pattern
Spurious and lost wake-ups
Comparing and swapping
More Threading Patterns
A bounded buffer
Strategy pattern – client polls
Strategy – taking over the polling and sleeping
Strategy – using condition variables
Reader or writer locks
A reader-friendly RW lock
A fair lock
Counting semaphores
Our own reentrant lock
Countdown latch
Implementing the countdown latch
A cyclic barrier
A future task
Thread Pools
Thread pools
The command design pattern
Counting words
Another version
The blocking queue
Thread interruption semantics
The fork-join pool
Egrep – simple version
Why use a recursive task?
Task parallelism
Quicksort – using fork-join
The ForkJoinQuicksortTask class
The copy-on-write theme
In-place sorting
The map-reduce theme
Work stealing
Active objects
Hiding and adapting
Using a proxy
Increasing the Concurrency