Here you can find the source of waitForEvents(long sleepTime, int expectedCount, AtomicInteger actualCount, long timeout)
public static void waitForEvents(long sleepTime, int expectedCount, AtomicInteger actualCount, long timeout) throws InterruptedException
//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 } }