Class Watchdog
java.lang.Object
org.apache.commons.exec.Watchdog
- All Implemented Interfaces:
Runnable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds ExecuteWatchdog instances. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<TimeoutObserver> Observers.private booleanWhether this is stopped.private final ThreadFactoryThe thread factory.private final DurationTimeout duration. -
Constructor Summary
ConstructorsModifierConstructorDescriptionWatchdog(long timeoutMillis) Deprecated.privateWatchdog(Watchdog.Builder builder) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a TimeoutObserver.static Watchdog.Builderbuilder()Creates a new builder.protected final voidFires a timeout occurred event for each observer.(package private) ThreadFactoryGets the thread factory.Gets the timeout.voidRemoves a TimeoutObserver.voidrun()voidstart()Starts a new thread.voidstop()Requests a thread stop.
-
Field Details
-
observers
Observers. -
timeout
Timeout duration. -
stopped
private boolean stoppedWhether this is stopped. -
threadFactory
The thread factory.
-
-
Constructor Details
-
Watchdog
Constructs a new instance.- Parameters:
threadFactory- the thread factory.timeout- the timeout duration.
-
Watchdog
Deprecated.Constructs a new instance.- Parameters:
timeoutMillis- 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. -
getThreadFactory
-
getTimeout
-
removeTimeoutObserver
Removes a TimeoutObserver.- Parameters:
to- a TimeoutObserver to remove.
-
run
-
start
public void start()Starts a new thread. -
stop
public void stop()Requests a thread stop.
-
Watchdog.Builder.get().