title: multiple schedule calls with single timer
body: <p>I am reading about timers in Java SDK 1.3</p>
  
  <p>It is mentioned as follows in POSA volume 2 in active object pattern</p>
  
  <blockquote>
    <p>JDK 1.3 introduced a mechansim for executing timer-based tasks
    concurrently in the classes java.util.Timer and java.util.TimerTask.
    When ever the scheduled execution time of a task occurs it is
    executed. The scheduling calls are executed in the clinets thread,
    while the tasks themselves are executed in a thread owned by Timer
    object. A timer internal task queue is protected by locks because the
    two threads outlined above operate on it concurrently.</p>
    
    <p>The task queue is implemented as a priority queue so that the next
    TimerTask to expire can be identified efficiently. The timer thread
    simply waits until this expiration.</p>
  </blockquote>
  
  <pre><code>public class Reminder {
      Timer timer;
  
      public Reminder(int seconds) {
          timer = new Timer();
          timer.schedule(new RemindTask(), seconds*1000);
      }
  
      class RemindTask extends TimerTask {
          public void run() {
              System.out.format("Time's up!%n");
              timer.cancel(); //Terminate the timer thread
          }
      }
  
      public static void main(String args[]) {
          new Reminder(5);
          System.out.format("Task scheduled.%n");
      }
  }
  </code></pre>
  
  <p>My question is </p>
  
  <ol>
  <li><p>Can we have multiple schedule functions with single timer? Request to give an example here and how it works. For example if we have two scheduled one task for every 5 seconds as shown above and another for every 12 seconds but I want to use same Reminder object instead of using another (i.e., creating) Reminder object. I want to know how internally it works like how timer stated like 5,5,2, 3, and so on . (as I have same kind of requirement in my project which I have to do in C++ with out using boost. I am planning to use single timer rather than multiple timers.</p></li>
  <li><p>What is delay argument here and how it is used. 
   schedule(TimerTask task, long delay, long period) </p></li>
  </ol>
  
  <p>Thanks for your time and help.</p>