Class StartupCountdown


  • public final class StartupCountdown
    extends Object
    Countdown tracker with capabilities similar to SE CountDownLatch, but allowing threads to mark and unmark themselves as privileged. Privileged threads, when entering await method, will immediately proceed without checking latch's state. This reentrant behaviour allows to work around situations where there is a possibility of a deadlock.
    Author:
    Fedor Gavrilov
    • Constructor Detail

      • StartupCountdown

        public StartupCountdown​(int count)
    • Method Detail

      • countDown

        public void countDown()
      • countUp

        public void countUp​(int count)
      • addCallback

        public void addCallback​(Runnable callback)
        Executes a lightweight action when the countdown reaches 0. If StartupCountdown is not at zero when the method is called, passed callback will be executed by the last thread to call countDown. If StartupCountdown is at zero already, passed callback will be executed immediately by the caller thread.
        Parameters:
        callback - to execute. Should not be null.
      • isPrivileged

        public boolean isPrivileged()