private void executeTrigger(Trigger trig) { setTimeOut(); // anything less than a couple hundred ms isn't worth creating a thread for. if (trig.getDelay() < 200) executeTriggerWithoutDelay(trig); else { // check to see if this trigger is already represented in the // list of pending trigger threads. Iterator<TriggerDelayThread> iter = triggerThreads.iterator(); boolean found = false; while (iter.hasNext()) { TriggerDelayThread th = iter.next(); if (th.equals(trig)) { found = true; break; } } if (!found) { // spawn a thread which will execute this trigger after the appropriate number of ms. TriggerDelayThread tdt = new TriggerDelayThread(trig, this); triggerThreads.add(tdt); tdt.start(); } } }
@Override public long getDelay() { return currentDelay + starting.getDelay(); }