peterreilly    2005/01/21 09:37:28

  Modified:    src/main/org/apache/tools/ant/util Watchdog.java
  Log:
  javadoc
  
  Revision  Changes    Path
  1.13      +29 -1     ant/src/main/org/apache/tools/ant/util/Watchdog.java
  
  Index: Watchdog.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/Watchdog.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Watchdog.java     29 Mar 2004 16:39:03 -0000      1.12
  +++ Watchdog.java     21 Jan 2005 17:37:28 -0000      1.13
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2002-2004 The Apache Software Foundation
  + * Copyright  2002-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -34,6 +34,10 @@
       private long timeout = -1;
       private boolean stopped = false;
   
  +    /**
  +     * Constructor for Watchdog.
  +     * @param timeout the timeout to use in milliseconds (must be >= 1).
  +     */
       public Watchdog(long timeout) {
           if (timeout < 1) {
               throw new IllegalArgumentException("timeout less than 1.");
  @@ -41,14 +45,25 @@
           this.timeout = timeout;
       }
   
  +    /**
  +     * Add a timeout observer.
  +     * @param to the timeout observer to add.
  +     */
       public void addTimeoutObserver(TimeoutObserver to) {
           observers.addElement(to);
       }
   
  +    /**
  +     * Remove a timeout observer.
  +     * @param to the timeout observer to remove.
  +     */
       public void removeTimeoutObserver(TimeoutObserver to) {
           observers.removeElement(to);
       }
   
  +    /**
  +     * Inform the observers that a timeout has occured.
  +     */
       protected final void fireTimeoutOccured() {
           Enumeration e = observers.elements();
           while (e.hasMoreElements()) {
  @@ -56,6 +71,9 @@
           }
       }
   
  +    /**
  +     * Start the watch dog.
  +     */
       public synchronized void start() {
           stopped = false;
           Thread t = new Thread(this, "WATCHDOG");
  @@ -63,11 +81,20 @@
           t.start();
       }
   
  +    /**
  +     * Stop the watch dog.
  +     */
       public synchronized void stop() {
           stopped = true;
           notifyAll();
       }
   
  +    /**
  +     * The run method of the watch dog thread.
  +     * This simply does a wait for the timeout time, and
  +     * if the stop flag has not been set when the wait has returned or
  +     * has been interrupted, the watch dog listeners are informed.
  +     */
       public synchronized void run() {
           final long until = System.currentTimeMillis() + timeout;
           long now;
  @@ -75,6 +102,7 @@
               try {
                   wait(until - now);
               } catch (InterruptedException e) {
  +                // Ignore exception
               }
           }
           if (!stopped) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to