Package org.frankframework.task
Class TimeoutGuard
java.lang.Object
org.frankframework.task.TimeoutGuard
TimeoutGuard interrupts running thread when timeout is exceeded.
- Since:
- 4.9.10
- Author:
- Gerrit van Brakel
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTimeoutGuard(int timeout, String description) Create a new TimeoutGuard and activate immediatelyTimeoutGuard(int timeout, String description, Runnable abortAction) Create a new TimeoutGuard and activate immediatelyTimeoutGuard(String description) Create a new TimeoutGuardTimeoutGuard(String description, Runnable abortAction) Create a new TimeoutGuard -
Method Summary
Modifier and TypeMethodDescriptionprotected voidabort()Deprecated.voidactivateGuard(int timeout) Sets and activates the timeoutbooleancancel()Cancels timer, and returns true if thread has been killed by this guard or interrupted by another.boolean
-
Field Details
-
log
protected org.apache.logging.log4j.Logger log
-
-
Constructor Details
-
TimeoutGuard
Create a new TimeoutGuard- Parameters:
description- name of the guard
-
TimeoutGuard
Create a new TimeoutGuard- Parameters:
description- name of the guardabortAction- lambda which will be triggered stop the process and cleanup the resources you are 'guarding'.
-
TimeoutGuard
Create a new TimeoutGuard and activate immediately- Parameters:
timeout- in secondsdescription- name of the guard
-
TimeoutGuard
Create a new TimeoutGuard and activate immediately- Parameters:
timeout- in secondsdescription- name of the guardabortAction- lambda which will be triggered stop the process and cleanup the resources you are 'guarding'.
-
-
Method Details
-
activateGuard
public void activateGuard(int timeout) Sets and activates the timeout- Parameters:
timeout- in seconds
-
cancel
public boolean cancel()Cancels timer, and returns true if thread has been killed by this guard or interrupted by another.
Call this in a finally-block to verify correct execution of the guarded process or if it has been interrupted by the guard. -
abort
Deprecated.Implement this method to stop the process and cleanup the resources you are 'guarding'. -
threadKilled
public boolean threadKilled()
-