Class ConditionVariable

    • Constructor Detail

      • ConditionVariable

        public ConditionVariable()
        Creates an instance using Clock.DEFAULT.
      • ConditionVariable

        public ConditionVariable​(Clock clock)
        Creates an instance, which starts closed.
        clock - The Clock whose Clock.elapsedRealtime() method is used to determine when block(long) should time out.
    • Method Detail

      • open

        public boolean open()
        Opens the condition and releases all threads that are blocked.
        True if the condition variable was opened. False if it was already open.
      • close

        public boolean close()
        Closes the condition.
        True if the condition variable was closed. False if it was already closed.
      • block

        public boolean block​(long timeoutMs)
                      throws InterruptedException
        Blocks until the condition is opened or until timeoutMs have passed.
        timeoutMs - The maximum time to wait in milliseconds. If timeoutMs <= 0 then the call will return immediately without blocking.
        True if the condition was opened, false if the call returns because of the timeout.
        InterruptedException - If the thread is interrupted.
      • blockUninterruptible

        public void blockUninterruptible()
        Blocks until the condition is open. Unlike block(), this method will continue to block if the calling thread is interrupted. If the calling thread was interrupted then its interrupted status will be set when the method returns.
      • isOpen

        public boolean isOpen()
        Returns whether the condition is opened.