// Path: src/main/java/com/lmax/disruptor/util/Util.java
// public static long getMinimumSequence(final Sequence[] sequences)
// {
//     long minimum = Long.MAX_VALUE;
// 
//     for (Sequence sequence : sequences)
//     {
//         long value = sequence.get();
//         minimum = minimum < value ? minimum : value;
//     }
// 
//     return minimum;
// }


import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import static com.lmax.disruptor.util.Util.getMinimumSequence;
    private final Lock lock = new ReentrantLock();
    private final Condition processorNotifyCondition = lock.newCondition();
    private volatile int numWaiters = 0;

    @Override
    public long waitFor(final long sequence, final Sequence cursor, final Sequence[] dependents, final SequenceBarrier barrier)
        throws AlertException, InterruptedException
    {
        long availableSequence;
        if ((availableSequence = cursor.get()) < sequence)
        {
            lock.lock();
            try
            {
                ++numWaiters;
                while ((availableSequence = cursor.get()) < sequence)
                {
                    barrier.checkAlert();
                    processorNotifyCondition.await();
                }
            }
            finally
            {
                --numWaiters;
                lock.unlock();
            }
        }

        if (0 != dependents.length)
        {
// Path: src/main/java/com/lmax/disruptor/util/Util.java
// public static long getMinimumSequence(final Sequence[] sequences)
// {
//     long minimum = Long.MAX_VALUE;
// 
//     for (Sequence sequence : sequences)
//     {
//         long value = sequence.get();
//         minimum = minimum < value ? minimum : value;
//     }
// 
//     return minimum;
// }


// Path: src/main/java/com/lmax/disruptor/BlockingWaitStrategy.java
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import static com.lmax.disruptor.util.Util.getMinimumSequence;

    private final Lock lock = new ReentrantLock();
    private final Condition processorNotifyCondition = lock.newCondition();
    private volatile int numWaiters = 0;

    @Override
    public long waitFor(final long sequence, final Sequence cursor, final Sequence[] dependents, final SequenceBarrier barrier)
        throws AlertException, InterruptedException
    {
        long availableSequence;
        if ((availableSequence = cursor.get()) < sequence)
        {
            lock.lock();
            try
            {
                ++numWaiters;
                while ((availableSequence = cursor.get()) < sequence)
                {
                    barrier.checkAlert();
                    processorNotifyCondition.await();
                }
            }
            finally
            {
                --numWaiters;
                lock.unlock();
            }
        }

        if (0 != dependents.length)
        {
            while ((availableSequence = getMinimumSequence(dependents)) < sequence)