Watchdog (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.util, class: Watchdog

Package org.apache.tools.ant.util

# Class Watchdog

java.lang.Object
org.apache.tools.ant.util.Watchdog

All Implemented Interfaces:
  `Runnable`

public class Watchdog extends Object implements Runnable
Generalization of `ExecuteWatchdog`

Since:
  Ant 1.5
See Also:
  - `ExecuteWatchdog`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `ERROR_INVALID_TIMEOUT`
  Error string.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Watchdog(long timeout)`
  Constructor for Watchdog.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addTimeoutObserver(TimeoutObserver to)`
  Add a timeout observer.
  `protected final void`
  `fireTimeoutOccured()`
  Inform the observers that a timeout has occurred.
  `void`
  `removeTimeoutObserver(TimeoutObserver to)`
  Remove a timeout observer.
  `void`
  `run()`
  The run method of the watch dog thread.
  `void`
  `start()`
  Start the watch dog.
  `void`
  `stop()`
  Stop the watch dog.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### ERROR_INVALID_TIMEOUT

    public static final String ERROR_INVALID_TIMEOUT
    Error string. "timeout less than 1."
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### Watchdog

    public Watchdog(long timeout)
    Constructor for Watchdog.
    Parameters:
      `timeout` - the timeout to use in milliseconds (must be >= 1).

- ## Method Details

  - ### addTimeoutObserver

    public void addTimeoutObserver(TimeoutObserver to)
    Add a timeout observer.
    Parameters:
      `to` - the timeout observer to add.

  - ### removeTimeoutObserver

    public void removeTimeoutObserver(TimeoutObserver to)
    Remove a timeout observer.
    Parameters:
      `to` - the timeout observer to remove.

  - ### fireTimeoutOccured

    protected final void fireTimeoutOccured()
    Inform the observers that a timeout has occurred. This happens in the watchdog thread.

  - ### start

    public void start()
    Start the watch dog.

  - ### stop

    public void stop()
    Stop the watch dog.

  - ### run

    public void run()
    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.
    Specified by:
      `run` in interface `Runnable`