This post originated from an RSS feed registered with Java Buzz
by Scott Delap.
Original Post: Flexible Event Delivery with Executors
Feed Title: ClientJava.com
Feed URL: http://www.clientjava.com/archives/wireless_mobile.rdf
Feed Description: Client/Desktop Related Java Development
Excellent article using concurrency utilities in association with event listeners. Lots of good ideas in this article about isolation, thread pooling, synchronization, etc.
Flexible Event Delivery with Executors Every Java programmer is familiar with the EventListener pattern of asynchronous event delivery. Most have also written the boilerplate code needed to manage listeners and deliver events to other components. Listeners are simple, familiar, flexible, and easy to implement, but they call into code written by other developers, which can cause problems:
* A slow listener can take too long to handle an event, starving the other listeners and possibly deadlocking your component.
* When you dispatch an event to listeners, you control which thread will deliver it. Typically, the developers who implement the listeners have no control over how events are delivered to their code.
* In a multimedia application, it is not clear how to synchronize GUI events (like animation and user actions) with other asynchronous event streams (like speech, sound, and video).
This article uses Doug Lea's Executor (now part of J2SE 5.0) to make event dispatch more flexible.