19 October 2008 - java_dev (original) (raw)
I have a one-to-many object relationship (1 Observable, n Observers), each of them being driven by a separate thread. Using PropertyChangeSupport, the data source will fire PropertyChange events and deliver them to the observers, which will deal with them in their own threads.
Let's suppose one of these returns from run(), so although it's still registered as a listener, it won't deal with the events (even worse, it may still store the incoming events, but not deal/dispose of them!)
I can think of some solutions to this, but I'd like to hear from any general practice in this case. The most general solution would be the exiting function notify a central system, which would unregister the object from any listeners. The original Observable would also become a special kind of Observer, in order to purge its listeners' list the 'departing' ones.