Package org.apache.commons.exec
Class Watchdog
java.lang.Object
org.apache.commons.exec.Watchdog
- All Implemented Interfaces:
Runnable
Generalization of
ExecuteWatchdog
.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builds ExecuteWatchdog instances. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Vector
<TimeoutObserver> private boolean
private final ThreadFactory
The thread factory.private final long
-
Constructor Summary
ConstructorsModifierConstructorDescriptionWatchdog
(long timeoutMillis) Deprecated.private
Watchdog
(ThreadFactory threadFactory, Duration timeout) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a TimeoutObserver.static Watchdog.Builder
builder()
Creates a new builder.protected final void
Fires a timeout occurred event for each observer.void
Removes a TimeoutObserver.void
run()
void
start()
Starts a new thread.void
stop()
Requests a thread stop.
-
Field Details
-
observers
-
timeoutMillis
private final long timeoutMillis -
stopped
private boolean stopped -
threadFactory
The thread factory.
-
-
Constructor Details
-
Watchdog
Deprecated.Constructs a new instance.- Parameters:
timeoutMillis
- the timeout duration.
-
Watchdog
Constructs a new instance.- Parameters:
threadFactory
- the thread factory.timeout
- the timeout duration.
-
-
Method Details
-
builder
Creates a new builder.- Returns:
- a new builder.
- Since:
- 1.4.0
-
addTimeoutObserver
Adds a TimeoutObserver.- Parameters:
to
- a TimeoutObserver to add.
-
fireTimeoutOccured
protected final void fireTimeoutOccured()Fires a timeout occurred event for each observer. -
removeTimeoutObserver
Removes a TimeoutObserver.- Parameters:
to
- a TimeoutObserver to remove.
-
run
public void run() -
start
public void start()Starts a new thread. -
stop
public void stop()Requests a thread stop.
-
Watchdog.Builder.get()
.