|Concurrent Programming in Java: Design Principles and Patterns|
|summary||Not for beginners, this advanced book is perhaps somewhat hard to follow in places but rewarding to those who persevere|
Concurrent Programming in Java: Design Principles and Patterns,
by Doug Lea
[Addison-Wesley, ISBN 0-201-69581-2]
A Book on Concurrent Programming
Concurrent Programming in Java is not just a book on Java threads. Rather, this 339 page book from JavaSoft's Java Series delves into the unique problems and solutions of concurrent programming. It just happens to use Java as its example language. Sure, you'll learn how to use Java constructs such as
notifyAll. But you'll also learn how to put them together properly in an architecture that works.
The book has an online site with an excellent overview and supplement (containing errata, code, applets, and more).
This was the first book dedicated to concurrent programming that I read. I absorbed it over the course of a month while dealing with serious threading issues in a major shipping product. Since then I've read half of Butenhof's Programming with POSIX Threads (which cites Lea's book), so I have a bit of perspective.
This is definitely not a book for the casual reader. If that's what you need or want, check out the aforementioned Butenhof book. They each deal with concurrent programming in general, but Butenhof's is easier to read (even has cartoons), explains things more accessibly, and overall is a better introduction.
However, if you want a book with no holds barred content, without frivolous diagrams and overblown examples, then this is it. It's a tough read. You have to work to understand how the examples illustrate the text. But we are better off that Lea does not spoon feed us. I came away from this book with a greater understanding of concurrent programming, and to that end it succeeded.
From the table of contents you can see that Lea begins with an introduction. Not only does it frame subsequent chapters, it contains an 8 page further readings section containing references on everything from threads in particular to related topics in general. Subsequent chapters also have a further readings section, though not as overwhelming as the first.
Chapters two and three cover safety and liveness issues, the Scylla and Charybdes of concurrent programming. The former ensures that your program works correctly (eg, no race conditions or deadlocks), and the latter ensures that it does so effectively (ie, not reduced to a single thread). Lea doesn't just explain the pitfalls, but demonstrates the designs and techniques to get around them.
The next chapter covers controlling a thread's action based on its state. I found the discussion of policies of how to proceed when in the wrong state particularly useful. And of course guarded suspension is pivotal in concurrent programming.
The final four chapters take us from raw building blocks to higher level constructs. Lea introduces patterns which serve to control concurrency, allow for services, organize flow, and coordinate everything. Need to solve the readers and writers problem? Want to join a few threads? Perhaps you need to use an assembly line? Or maybe you're interested in transactions? These chapters have all that, and then some.
I find this book useful, even when I'm not doing Java. The only thing that stops me from purchasing my own copy is that another is readily accessible, and I hope that a second edition will come out that I can get instead!
It's a good book on concurrent programming. I just think it is only worth tackling if you have a strong backing in computer programming, and perhaps design patterns. Then, the text will make more sense and will serve as a good reference.
If you're more of a beginner or intermediate, I'd look elsewhere for a more appropriate book. You'll be better served than by struggling through this one. But certainly come back to it when you can!
Pick this book up at Amazon.
TABLE OF CONTENTS
Applications of Concurrency, Overview, Java Concurrency Support, Further Readings
Safe Objects, Immutable Objects, Fully Synchronized Objects, Contained Objects, Further Readings
Liveness Failures, Instance Variable Analysis, Splitting Synchronization, Further Readings
Policies, Representing State, Guarded Suspension, Balking, Further Readings
Subclassing, Adapters and Delegation, Acceptors, Models and Mappings, Further Readings
Services in Threads
Styles and Policies, Commands, Completion, Group Services, Coexistence, Further Readings
Applications, Flow Policies, Resource Management, Assembly Line, Further Readings
Transactions, Notification, Scheduling, Further Readings