private void sched(TimerTask task,long time,long period){
  if (time < 0)   throw new IllegalArgumentException("Illegal execution time.");
  if (Math.abs(period) > (Long.MAX_VALUE >> 1))   period>>=1;
synchronized (queue) {
    if (!thread.newTasksMayBeScheduled)     throw new IllegalStateException("Timer already cancelled.");
synchronized (task.lock) {
      if (task.state != TimerTask.VIRGIN)       throw new IllegalStateException("Task already scheduled or cancelled");
      task.nextExecutionTime=time;
      task.period=period;
      task.state=TimerTask.SCHEDULED;
    }
    queue.add(task);
    if (queue.getMin() == task)     queue.notify();
  }
}

private void sched ( TimerTask task , long time , long period ) { if ( time < 0 ) throw new IllegalArgumentException ( "Illegal execution time." ) ; if ( Math . abs ( period ) > ( Long . MAX_VALUE > > 1 ) ) period >>= 1 ; synchronized ( queue ) { if ( ! thread . newTasksMayBeScheduled ) throw new IllegalStateException ( "Timer already cancelled." ) ; synchronized ( task . lock ) { if ( task . state != TimerTask . VIRGIN ) throw new IllegalStateException ( "Task already scheduled or cancelled" ) ; task . nextExecutionTime = time ; task . period = period ; task . state = TimerTask . SCHEDULED ; } queue . add ( task ) ; if ( queue . getMin ( ) == task ) queue . notify ( ) ; } }
schedule the specified timer task for execution at the specified time with the specified period , in milliseconds . if period is positive , the task is scheduled for repeated execution ; if period is zero , the task is scheduled for one - time execution . time is specified in date . gettime ( ) format . this method checks timer state , task state , and initial execution time , but not period .
