Java AtomicInteger waitForEvents(long sleepTime, int expectedCount, AtomicInteger actualCount, long timeout)

Here you can find the source of waitForEvents(long sleepTime, int expectedCount, AtomicInteger actualCount, long timeout)

Description

wait For Events

License

Apache License

Declaration

public static void waitForEvents(long sleepTime, int expectedCount,
            AtomicInteger actualCount, long timeout)
            throws InterruptedException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.concurrent.atomic.AtomicInteger;

public class Main {
    public static void waitForEvents(long sleepTime, int expectedCount,
            AtomicInteger actualCount, long timeout)
            throws InterruptedException {
        long currentWaitTime = 0;
        long startTime = System.currentTimeMillis();
        while ((actualCount.get() < expectedCount)
                && (currentWaitTime <= timeout)) {
            Thread.sleep(sleepTime);
            currentWaitTime = System.currentTimeMillis() - startTime;
        }//from  w w w  .  java2  s.c  o m
    }
}

Related

  1. timeToId(long timeInMillis)
  2. tokenize(String string)
  3. uniqueSequenceId()
  4. waitForAll(List> futures)
  5. waitForEvents(long sleepTime, AtomicBoolean condition, long timeout)
  6. waitForEvents(long sleepTime, int expectedCount, AtomicInteger actualCount, long timeout)