Class CatchSignals


  • public class CatchSignals
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      CatchSignals()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void setup​(java.util.concurrent.atomic.AtomicBoolean signalCaught)
      Sets up a signal handler for SIGTERM and SIGINT, where a given AtomicBoolean gets a true value when the signal is caught.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CatchSignals

        public CatchSignals()
    • Method Detail

      • setup

        public static void setup​(java.util.concurrent.atomic.AtomicBoolean signalCaught)
        Sets up a signal handler for SIGTERM and SIGINT, where a given AtomicBoolean gets a true value when the signal is caught. Callers basically have two options for acting on the signal: They may choose to synchronize and wait() on this variable, and they will be notified when it changes state to true. To avoid problems with spurious wakeups, use a while loop and wait() again if the state is still false. As soon as the caller has been woken up and the state is true, the application should exit as soon as possible. They may also choose to poll the state of this variable. As soon as its state becomes true, the signal has been received, and the application should exit as soon as possible.
        Parameters:
        signalCaught - set to false initially, will be set to true when SIGTERM or SIGINT is caught.