Concurrent Patterns and Best Practices
Atul S. Khot更新时间:2021-07-16 17:32:57
最新章节:Leave a review - let other readers know what you think封面
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
Summary
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
Summary
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
Summary
Increasing the Concurrency
A lock-free stack
Atomic references
The stack implementation
A lock-free FIFO queue
How the flow works
A lock-free queue
Going lock-free
The enque(v) method
The deq() method
Concurrent execution of the enque and deque methods
The ABA problem
Thread locals
Pooling the free nodes
The atomic stamped reference
Concurrent hashing
The add(v) method
The need to resize
The contains(v) method
The big lock approach
The resizing strategy
The lock striping design pattern
Summary
Functional Concurrency Patterns
Immutability
Unmodifiable wrappers
Persistent data structures
Recursion and immutability
Futures
The apply method
by-name parameters
Future – thread mapping
Futures are asynchronous
Blocking is bad
Functional composition
Summary
Actors Patterns
Message driven concurrency
What is an actor?
Let it crash
Location transparency
Actors are featherlight
State encapsulation
Where is the parallelism?
Unhandled messages
The become pattern
Making the state immutable
Let it crash - and recover
Actor communication – the ask pattern
Actors talking with each another
Actor communication – the tell pattern
The pipeTo pattern
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
更新时间:2021-07-16 17:32:57