Esempio n. 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);
  }
Esempio n. 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);
  }
Esempio n. 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();
   }
 }
Esempio n. 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();
   }
 }