FileDocCategorySizeDatePackage
CharacterEventHandler.javaAPI DocExample760Sat Apr 17 22:07:04 BST 2004javathreads.examples.ch08.example2

CharacterEventHandler

public class CharacterEventHandler extends Object

Fields Summary
private ArrayList
listeners
Constructors Summary
Methods Summary
public synchronized voidaddCharacterListener(CharacterListener cl)


         
        listeners.add(cl);
    
public synchronized voidfireNewCharacter(CharacterSource source, int c)

        CharacterEvent ce = new CharacterEvent(source, c);
        CharacterListener[] cl = (CharacterListener[] )
                                 listeners.toArray(new CharacterListener[0]);
        for (int i = 0; i < cl.length; i++)
            cl[i].newCharacter(ce);
    
public synchronized voidremoveCharacterListener(CharacterListener cl)

        listeners.remove(cl);