Skip to content

Instantly share code, notes, and snippets.

@notyy
Created October 31, 2011 05:22
Show Gist options
  • Select an option

  • Save notyy/1326956 to your computer and use it in GitHub Desktop.

Select an option

Save notyy/1326956 to your computer and use it in GitHub Desktop.
is this efficent?
class Dispatcher {
private List data = new ArrayList();
private List listeners = new ArrayList();
public synchronized onNewData(byte[] newData){
updateData()
notifyListeners(newData)
}
public synchronized register(Listener l) {
//send all current data to l
l.sendAll(data);
listeners.add(l);
}
private notifyListeners(byte[] newData) {
for(l:listeners){
l.sendData(newData)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment