When the World is Running Down
Finding and fixing bugs in heavily concurrent code
A strong understanding of concurrency and threading is one of the traits that distinguishes the best Java developers, in every permutation of the platform. Servers by their very nature are heavily multi-threaded, good desktop developers know to thread off expensive work and unblock AWT-Event-Dispatch, and ME developers often have to carefully manage threads and other resources in order to coexist with other apps in the same small VM.
The concurrency utilities introduced in Java 5.0 offer various ways to achieve high efficiency with threads. For example, the
ReadWriteLock interface and
ReentrantReadWriteLock class give you a convenient means of providing concurrent read-many, write-once access to some resource.
It also provides some means of thoroughly messing up your application. What if you forget to unlock? Or what if you have a read lock and you try to perform a write operation? These mistakes can create subtle, hard-to-fix bugs.
This article was not written just to tell you about these pitfalls and send you on your way, but also to introduce a solution, which comes as an extension to the ReentrantReadWriteLock class. This extension (actually a composition) will wrap the lock and add more capabilities to help you overcome the specified problems.
In Java Today,
the Filthy Rich Clients project hosts sample code for the upcoming book of the same name by Chet Haase and Romain Guy. On his blog, Romain recently announced the availability of demos for chapters 5 (Performance) and 6 (Composites). Ultimately, the project will host the complete collection of demos and examples found in the book
The 360Mobile.us blog has published an interview with Mobile & Embedded Community Leader Roger Brinkley. "Roger and I had a chance to visit recently and talk more about his involvement in leading the community. Read on to learn a little more about what goes on behind the scenes in this thriving community..."