Methods Summary |
---|
public void | addCharacterListener(CharacterListener cl)
handler.addCharacterListener(cl);
|
public int | getPauseTime(int minTime, int maxTime)
return (int) (minTime + ((maxTime-minTime)*random.nextDouble()));
|
public int | getPauseTime()
return getPauseTime(2000, 5500);
|
public void | nextCharacter()
handler.fireNewCharacter(this,
(int) chars[random.nextInt(chars.length)]);
|
public void | removeCharacterListener(CharacterListener cl)
handler.removeCharacterListener(cl);
|
public void | run()
try {
lock.lock();
while (true) {
try {
if (done) {
cv.await();
} else {
nextCharacter();
cv.await(getPauseTime(), TimeUnit.MILLISECONDS);
}
} catch (InterruptedException ie) {
return;
}
}
} finally {
lock.unlock();
}
|
public void | setDone(boolean b)
try {
lock.lock();
done = b;
if (!done) cv.signal();
} finally {
lock.unlock();
}
|