We usually use observer pattern like following
[b]What’s wrong with this (in a multithreaded context)?
[/b]
[i]public synchronized void addListener(listener) {…}
public synchronized void setValue(newValue) {
myValue = newValue;
for (int i = 0; i < myListeners.length; i++) {
myListeners[i].valueChanged(newValue)
}
}[/i]
[b]What’s wrong with this (in a multithreaded context)?
[/b]