Class ConditionLatch


  • public class ConditionLatch
    extends Object
    This is similar to a normal CountDownLatch but it uses a wrapped lock for synchronising as well as a new corresponding condition for signalling. This allows to have a latch that releases a lock when waiting for the latch.
    • Field Detail

      • lock

        protected final Lock lock
        The lock which to use for synchronising.
      • cond

        protected final Condition cond
        The condition on which to wait for the latch.
      • count

        protected long count
        The number of releases before this latch releases threads.
    • Constructor Detail

      • ConditionLatch

        public ConditionLatch​(Lock lock)
        Creates a new latch with the designated latch and a count of 1.
        Parameters:
        lock - The lock with which to synchronise access to this latch.
      • ConditionLatch

        public ConditionLatch​(Lock lock,
                              long count)
        Creates a new latch with the designated latch and the designated count.
        Parameters:
        lock - The lock with which to synchronise access to this latch.
        count - The number of releases before this latch releases threads.