/* * Schedule a task. */ private void scheduleImpl(TimerTask task, long delay, long period, boolean fixed) { synchronized (impl) { if (impl.cancelled) { throw new IllegalStateException("luni.41"); // $NON-NLS-1$ } long when = delay + System.currentTimeMillis(); if (when < 0) { throw new IllegalArgumentException("luni.42"); // $NON-NLS-1$ } synchronized (task.lock) { if (task.isScheduled()) { throw new IllegalStateException("luni.43"); // $NON-NLS-1$ } if (task.cancelled) { throw new IllegalStateException("luni.44"); // $NON-NLS-1$ } task.when = when; task.period = period; task.fixedRate = fixed; } // insert the newTask into queue impl.insertTask(task); } }