private List listeners = new ArrayList();
public void addCharacterListener(CharacterListener cl) {
synchronized(listeners) {
listeners.add(cl);
}
}
public void removeCharacterListener(CharacterListener cl) {
synchronized(listeners) {
listeners.remove(cl);
}
}
public void fireNewCharacter(CharacterSource source, int c) {
CharacterEvent ce = new CharacterEvent(source, c);
CharacterListener[] cl;
synchronized(listeners) {
cl = (CharacterListener[])listeners.toArray(new CharacterListener[0]);
}
for(int i=0; i<cl.length; i++)
cl[i].newCharacter(ce);
}
public void addCharacterListener(CharacterListener cl) {
synchronized(listeners) {
listeners.add(cl);
}
}
public void removeCharacterListener(CharacterListener cl) {
synchronized(listeners) {
listeners.remove(cl);
}
}
public void fireNewCharacter(CharacterSource source, int c) {
CharacterEvent ce = new CharacterEvent(source, c);
CharacterListener[] cl;
synchronized(listeners) {
cl = (CharacterListener[])listeners.toArray(new CharacterListener[0]);
}
for(int i=0; i<cl.length; i++)
cl[i].newCharacter(ce);
}
——————————————————————————————————
傲轩游戏网
傲轩游戏网