Class ShutdownSignalBarrier


  • public class ShutdownSignalBarrier
    extends java.lang.Object
    One time barrier for blocking one or more threads until a SIGINT or SIGTERM signal is received from the operating system or by programmatically calling signal(). Useful for shutting down a service.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.CountDownLatch latch  
      private static java.util.ArrayList<java.util.concurrent.CountDownLatch> LATCHES  
      private static java.lang.String[] SIGNAL_NAMES
      Signals the barrier will be registered for.
    • Constructor Summary

      Constructors 
      Constructor Description
      ShutdownSignalBarrier()
      Construct and register the barrier ready for use.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void await()
      Await the reception of the shutdown signal.
      void remove()
      Remove the barrier from the shutdown signals.
      void signal()
      Programmatically signal awaiting threads on the latch associated with this barrier.
      void signalAll()
      Programmatically signal all awaiting threads.
      private static void signalAndClearAll()  
      • Methods inherited from class java.lang.Object

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

      • SIGNAL_NAMES

        private static final java.lang.String[] SIGNAL_NAMES
        Signals the barrier will be registered for.
      • LATCHES

        private static final java.util.ArrayList<java.util.concurrent.CountDownLatch> LATCHES
      • latch

        private final java.util.concurrent.CountDownLatch latch
    • Constructor Detail

      • ShutdownSignalBarrier

        public ShutdownSignalBarrier()
        Construct and register the barrier ready for use.
    • Method Detail

      • signal

        public void signal()
        Programmatically signal awaiting threads on the latch associated with this barrier.
      • signalAll

        public void signalAll()
        Programmatically signal all awaiting threads.
      • remove

        public void remove()
        Remove the barrier from the shutdown signals.
      • await

        public void await()
        Await the reception of the shutdown signal.
      • signalAndClearAll

        private static void signalAndClearAll()