Example #1
0
  public void resetTypist(CharacterSource newTypist) {
    CharacterSource oldTypist;

    if (newTypist != null) newTypist.addCharacterListener(this);

    oldTypist = typist.getAndSet(newTypist);
    if (oldTypist != null) oldTypist.removeCharacterListener(this);
  }
Example #2
0
  public void resetGenerator(CharacterSource newGenerator) {
    /** 注意这个方法的算法更改逻辑 */
    CharacterSource oldGenerator;

    if (newGenerator != null) newGenerator.addCharacterListener(this);

    oldGenerator = generator.getAndSet(newGenerator);
    if (oldGenerator != null) oldGenerator.removeCharacterListener(this);
  }
Example #3
0
 public void resetTypist(CharacterSource newTypist) {
   try {
     scoreLock.lock();
     if (typist != null) typist.removeCharacterListener(this);
     typist = newTypist;
     if (typist != null) typist.addCharacterListener(this);
   } finally {
     scoreLock.unlock();
   }
 }
Example #4
0
 public void resetGenerator(CharacterSource newGenerator) {
   try {
     scoreLock.lock();
     if (generator != null) generator.removeCharacterListener(this);
     generator = newGenerator;
     if (generator != null) generator.addCharacterListener(this);
   } finally {
     scoreLock.unlock();
   }
 }