Class TimeoutGuard

java.lang.Object
org.frankframework.task.TimeoutGuard

public class TimeoutGuard extends Object
TimeoutGuard interrupts running thread when timeout is exceeded.
Since:
4.9.10
Author:
Gerrit van Brakel
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.logging.log4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimeoutGuard(int timeout, String description)
    Create a new TimeoutGuard and activate immediately
    TimeoutGuard(String description)
    Create a new TimeoutGuard
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Implement this method to stop the process and cleanup the resources you are 'guarding'.
    void
    activateGuard(int timeout)
    Sets and activates the timeout
    boolean
    Cancels timer, and returns true if thread has been killed by this guard or interrupted by another.
    boolean
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • log

      protected org.apache.logging.log4j.Logger log
  • Constructor Details

    • TimeoutGuard

      public TimeoutGuard(String description)
      Create a new TimeoutGuard
      Parameters:
      description - name of the guard
    • TimeoutGuard

      public TimeoutGuard(int timeout, String description)
      Create a new TimeoutGuard and activate immediately
      Parameters:
      timeout - in seconds
      description - 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()