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
-
Constructor Summary
ConstructorDescriptionTimeoutGuard
(int timeout, String description) Create a new TimeoutGuard and activate immediatelyTimeoutGuard
(String description) Create a new TimeoutGuard -
Method Summary
Modifier and TypeMethodDescriptionprotected void
abort()
Implement this method to stop the process and cleanup the resources you are 'guarding'.void
activateGuard
(int timeout) Sets and activates the timeoutboolean
cancel()
Cancels timer, and returns true if thread has been killed by this guard or interrupted by another.void
setDescription
(String description) 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 and activate immediately- Parameters:
timeout
- in secondsdescription
- name of the guard
-
-
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
protected void abort()Implement this method to stop the process and cleanup the resources you are 'guarding'. -
threadKilled
public boolean threadKilled() -
getDescription
-
setDescription
-