示例#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();
      }
    }
  }
示例#2
0
 /* (non-Javadoc)
  * @see v9t9.common.keyboard.IKeyboardState#addKeyboardListener(v9t9.common.keyboard.IKeyboardListener)
  */
 @Override
 public synchronized void addKeyboardListener(IKeyboardListener listener) {
   listeners.add(listener);
 }
示例#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();
   }
 }