Exemplo n.º 1
0
  /**
   * Schedule a task to occur the given number of times per second.
   *
   * @param task
   * @param perSecond
   */
  public void scheduleTask(Runnable task, long perSecond) {
    synchronized (controlLock) {
      for (RunnableInfo info : taskinfos) if (info.task == task) return;

      if (perSecond != 0) {
        RunnableInfo info = new RunnableInfo(task, NS / perSecond);
        taskinfos.add(info);

        if (timerThread == null) startTimer();
      }
    }
  }
Exemplo n.º 2
0
 /* (non-Javadoc)
  * @see v9t9.common.keyboard.IKeyboardState#addKeyboardListener(v9t9.common.keyboard.IKeyboardListener)
  */
 @Override
 public synchronized void addKeyboardListener(IKeyboardListener listener) {
   listeners.add(listener);
 }
Exemplo n.º 3
0
 /**
  * Invoke a runnable as soon as possible
  *
  * @param runnable
  */
 public void invoke(Runnable runnable) {
   synchronized (controlLock) {
     invokes.add(runnable);
     if (timerThread == null) startTimer();
   }
 }