Beispiel #1
0
 synchronized void stop() {
   if (isRunning()) {
     ticker.cancel(true); // may interrupt if running
     ticker = null;
   }
   // let any threads waiting on the clock fall through
   synchronized (ticks) {
     // one should be sufficient but this is to be safe
     for (int i = 0; i < 5; i++) {
       ticks.notifyAll();
       try {
         Thread.sleep(10);
       } catch (InterruptedException ignored) {
       }
     }
   }
 }
Beispiel #2
0
 private void incrementTicks() {
   synchronized (ticks) {
     ticks.increment();
     ticks.notifyAll();
   }
 }