| |
| |
Listings | |
| |
| |
Preface | |
| |
| |
| |
Introduction | |
| |
| |
| |
A (very) brief history of concurrency | |
| |
| |
| |
Benefits of threads | |
| |
| |
| |
Risks of threads | |
| |
| |
| |
Threads are everywhere | |
| |
| |
| |
Fundamentals | |
| |
| |
| |
Thread Safety | |
| |
| |
| |
What is thread safety? | |
| |
| |
| |
Atomicity | |
| |
| |
| |
Locking | |
| |
| |
| |
Guarding state with locks | |
| |
| |
| |
Liveness and performance | |
| |
| |
| |
Sharing Objects | |
| |
| |
| |
Visibility | |
| |
| |
| |
Publication and escape | |
| |
| |
| |
Thread confinement | |
| |
| |
| |
Immutability | |
| |
| |
| |
Safe publication | |
| |
| |
| |
Composing Objects | |
| |
| |
| |
Designing a thread-safe class | |
| |
| |
| |
Instance confinement | |
| |
| |
| |
Delegating thread safety | |
| |
| |
| |
Adding functionality to existing thread-safe classes | |
| |
| |
| |
Documenting synchronization policies | |
| |
| |
| |
Building Blocks | |
| |
| |
| |
Synchronized collections | |
| |
| |
| |
Concurrent collections | |
| |
| |
| |
Blocking queues and the producer-consumer pattern | |
| |
| |
| |
Blocking and interruptible methods | |
| |
| |
| |
Synchronizers | |
| |
| |
| |
Building an efficient, scalable result cache | |
| |
| |
| |
Structuring Concurrent Applications | |
| |
| |
| |
Task Execution | |
| |
| |
| |
Executing tasks in threads | |
| |
| |
| |
The Executor framework | |
| |
| |
| |
Finding exploitable parallelism | |
| |
| |
| |
Cancellation and Shutdown | |
| |
| |
| |
Task cancellation | |
| |
| |
| |
Stopping a thread-based service | |
| |
| |
| |
Handling abnormal thread termination | |
| |
| |
| |
JVM shutdown | |
| |
| |
| |
Applying Thread Pools | |
| |
| |
| |
Implicit couplings between tasks and execution policies | |
| |
| |
| |
Sizing thread pools | |
| |
| |
| |
Configuring ThreadPoolExecutor | |
| |
| |
| |
Extending ThreadPoolExecutor | |
| |
| |
| |
Parallelizing recursive algorithms | |
| |
| |
| |
GUI Applications | |
| |
| |
| |
Why are GUIs single-threaded? | |
| |
| |
| |
Short-running GUI tasks | |
| |
| |
| |
Long-running GUI tasks | |
| |
| |
| |
Shared data models | |
| |
| |
| |
Other forms of single-threaded subsystems | |
| |
| |
| |
Liveness, Performance, and Testing | |
| |
| |
| |
Avoiding Liveness Hazards | |
| |
| |
| |
Deadlock | |
| |
| |
| |
Avoiding and diagnosing deadlocks | |
| |
| |
| |
Other liveness hazards | |
| |
| |
| |
Performance and Scalability | |
| |
| |
| |
Thinking about performance | |
| |
| |
| |
Amdahl's law | |
| |
| |
| |
Costs introduced by threads | |
| |
| |
| |
Reducing lock contention | |
| |
| |
| |
Example: Comparing Map performance | |
| |
| |
| |
Reducing context switch overhead | |
| |
| |
| |
Testing Concurrent Programs | |
| |
| |
| |
Testing for correctness | |
| |
| |
| |
Testing for performance | |
| |
| |
| |
Avoiding performance testing pitfalls | |
| |
| |
| |
Complementary testing approaches | |
| |
| |
| |
Advanced Topics | |
| |
| |
| |
Explicit Locks | |
| |
| |
| |
Lock and ReentrantLock | |
| |
| |
| |
Performance considerations | |
| |
| |
| |
Fairness | |
| |
| |
| |
Choosing between synchronized and ReentrantLock | |
| |
| |
| |
Read-write locks | |
| |
| |
| |
Building Custom Synchronizers | |
| |
| |
| |
Managing state dependence | |
| |
| |
| |
Using condition queues | |
| |
| |
| |
Explicit condition objects | |
| |
| |
| |
Anatomy of a synchronizer | |
| |
| |
| |
AbstractQueuedSynchronizer | |
| |
| |
| |
AQS in java.util.concurrent synchronizer classes | |
| |
| |
| |
Atomic Variables and Nonblocking Synchronization | |
| |
| |
| |
Disadvantages of locking | |
| |
| |
| |
Hardware support for concurrency | |
| |
| |
| |
Atomic variable classes | |
| |
| |
| |
Nonblocking algorithms | |
| |
| |
| |
The Java Memory Model | |
| |
| |
| |
What is a memory model, and why would I want one? | |
| |
| |
| |
Publication | |
| |
| |
| |
Initialization safety | |
| |
| |
| |
Annotations for Concurrency | |
| |
| |
| |
Class annotations | |
| |
| |
| |
Field and method annotations | |
| |
| |
Bibliography | |
| |
| |
Index | |