Java Concurrency in Practice EN
- Jazyk: anglický
- Žáner: Knižky v cudzom jazyku
- Počet strán: 384
- Rok vydania: 2006
Java Concurrency in Practice EN
- Jazyk: anglický
- Žáner: Knižky v cudzom jazyku
- Počet strán: 384
- Rok vydania: 2006
Na túto knižku aktuálne nikto nečaká, máš záujem ty?
Aktuálne nikto neponúka túto knihu.
Chcem predať túto knihu
Chcem si kúpiť, pošlite mi notifikáciu o novej ponuke
Popis knihy
As processors become faster and multiprocessor systems become cheaper, the need to take advantage of multithreading in order to achieve full hardware resource utilization only increases the importance of being able to incorporate concurrency in a wide variety of application categories. For many developers, concurrency remains a mystery. Developing, testing and debugging multithreaded programs is extremely difficult because concurrency hazards do not manifest themselves uniformly or reliably. This book is intended to be neither an introduction to concurrency (any threading chapter in an intro book does that) nor is it an encyclopedic reference of All Things Concurrency (that would be Doug Lea's Concurrent Programming in Java). Instead, this title is a combination of concepts, guidelines, and examples intended to assist developers in the difficult process of understanding concurrency and its new tools in J2SE 5.0. Filled with contributions from Java gurus such as Josh Bloch, David Holmes and Doug Lea, this book provides any Java programmers with the basic building blocks they need to gain a basic understanding of concurrency and its benefits. Table of Contents Listings xii Preface xvii Chapter 1: Introduction 1 1.1A (very) brief history of concurrency 1 1.2Benefits of threads3 1.3Risks of threads 5 1.4Threads are everywhere 9 Part I: Fundamentals 13 Chapter 2: Thread Safety 15 2.1What is thread safety?17 2.2Atomicity 19 2.3Locking 23 2.4Guarding state with locks27 2.5Liveness and performance 29 Chapter 3: Sharing Objects 33 3.1Visibility33 3.2Publication and escape 39 3.3Thread confinement 42 3.4Immutability 46 3.5Safepublication 49 Chapter 4: Composing Objects 55 4.1Designing a thread-safe class55 4.2Instance confinement58 4.3Delegating thread safety62 4.4Adding functionality to existing thread-safe classes 71 4.5Documenting synchronization policies 74 Chapter 5: Building Blocks 79 5.1Synchronized collections 79 5.2Concurrent collections 84 5.3Blocking queues and the producer-consumer pattern 87 5.4Blocking and interruptible methods 92 5.5Synchronizers 94 5.6Building an efficient, scalable result cache101 Part II: Structuring Concurrent Applications 111 Chapter 6: Task Execution 113 6.1Executing tasks in threads113 6.2The Executor framework 117 6.3Finding exploitable parallelism123 Chapter 7: Cancellation and Shutdown 135 7.1Task cancellation135 7.2Stopping a thread-based service 150 7.3Handling abnormal thread termination 161 7.4JVM shutdown164 Chapter 8: Applying Thread Pools 167 8.1Implicit couplings between tasks and execution policies 167 8.2Sizing thread pools170 8.3Configuring ThreadPoolExecutor 171 8.4Extending ThreadPoolExecutor 179 8.5Parallelizing recursive algorithms 181 Chapter 9: GUI Applications 189 9.1Why are GUIs single-threaded?189 9.2Short-running GUI tasks 192 9.3Long-running GUI tasks 195 9.4Shared data models 198 9.5Other forms of single-threaded subsystems202 Part III: Liveness, Performance, and Testing 203 Chapter 10: Avoiding Liveness Hazards 205 10.1Deadlock 205 10.2Avoiding and diagnosing deadlocks 215 10.3Other liveness hazards218 Chapter 11: Performance and Scalability 221 11.1Thinking about performance221 11.2Amdahl's law 225 11.3Costs introduced by threads 229 11.4Reducing lock contention232 11.5Example: Comparing Map performance 242 11.6Reducing context switch overhead243 Chapter 12: Testing Concurrent Programs 247 12.1Testing for correctness 248 12.2Testing for performance260 12.3Avoiding performance testing pitfalls 266 12.4Complementary testing approaches 270 Part IV: Advanced Topics 275 Chapter 13: Explicit Locks 277 13.1Lock and ReentrantLock277 13.2Performance considerations282 13.3Fairness283 13.4Choosing between synchronized and ReentrantLock285 13.5Read-write locks 286 Chapter 14: Building Custom Synchronizers 291 14.1Managing state dependence291 14.2Using condition queues298 14.3Explicit condition objects 306 14.4Anatomy of a synchronizer 308 14.5AbstractQueuedSynchronizer311 14.6AQS in java.util.concurrent synchronizer classes314 Chapter15: Atomic Variables and Nonblocking Synchronization 319 15.1Disadvantages of locking 319 15.2Hardware support for concurrency321 15.3Atomic variable classes 324 15.4Nonblocking algorithms329 Chapter 16: The Java Memory Model 337 16.1What is a memory model, and why would I want one? 337 16.2Publication 344 16.3Initialization safety 349 Appendix A: Annotations for Concurrency 353 A.1Class annotations 353 A.2Field andmethod annotations353 Bibliography 355 Index 359
Našli ste chybu?