/** * 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(); } } }
/* (non-Javadoc) * @see v9t9.common.keyboard.IKeyboardState#addKeyboardListener(v9t9.common.keyboard.IKeyboardListener) */ @Override public synchronized void addKeyboardListener(IKeyboardListener listener) { listeners.add(listener); }
/** * Invoke a runnable as soon as possible * * @param runnable */ public void invoke(Runnable runnable) { synchronized (controlLock) { invokes.add(runnable); if (timerThread == null) startTimer(); } }