Top Description Fields Constructors Methods
org.apache.tools.ant.util

public Class Watchdog

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.util.ArrayList, .Collections, .List

Generalization of ExecuteWatchdog
Since
Ant 1.5
See Also
org.apache.tools.ant.taskdefs.ExecuteWatchdog

Field Summary

Modifier and TypeField and Description
public static final String
ERROR_INVALID_TIMEOUT

Error string.

private List<TimeoutObserver>
private volatile boolean
stopped

marked as volatile to stop the compiler caching values or (in java1.5+, reordering access)

private long

Constructor Summary

AccessConstructor and Description
public
Watchdog(long
the timeout to use in milliseconds (must be >= 1).
timeout
)

Constructor for Watchdog.

Method Summary

Modifier and TypeMethod and Description
public void
addTimeoutObserver(TimeoutObserver
the timeout observer to add.
to
)

Add a timeout observer.

protected final void
fireTimeoutOccured()

Inform the observers that a timeout has occurred.

public void
removeTimeoutObserver(TimeoutObserver
the timeout observer to remove.
to
)

Remove a timeout observer.

public synchronized void
run()

Implements java.lang.Runnable.run.

The run method of the watch dog thread.
public synchronized void
start()

Start the watch dog.

public synchronized void
stop()

Stop the watch dog.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ERROR_INVALID_TIMEOUTback to summary
public static final String ERROR_INVALID_TIMEOUT

Error string. timeout less than 1.

observersback to summary
private List<TimeoutObserver> observers
stoppedback to summary
private volatile boolean stopped

marked as volatile to stop the compiler caching values or (in java1.5+, reordering access)

timeoutback to summary
private long timeout

Constructor Detail

Watchdogback to summary
public Watchdog(long timeout)

Constructor for Watchdog.

Parameters
timeout:long

the timeout to use in milliseconds (must be >= 1).

Method Detail

addTimeoutObserverback to summary
public void addTimeoutObserver(TimeoutObserver to)

Add a timeout observer.

Parameters
to:TimeoutObserver

the timeout observer to add.

fireTimeoutOccuredback to summary
protected final void fireTimeoutOccured()

Inform the observers that a timeout has occurred. This happens in the watchdog thread.

removeTimeoutObserverback to summary
public void removeTimeoutObserver(TimeoutObserver to)

Remove a timeout observer.

Parameters
to:TimeoutObserver

the timeout observer to remove.

runback to summary
public synchronized void run()

Implements java.lang.Runnable.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.

Annotations
@Override
startback to summary
public synchronized void start()

Start the watch dog.

stopback to summary
public synchronized void stop()

Stop the watch dog.