/** * Waits until total number of events processed is equal or greater then argument passed. * * @param cnt Number of events to wait. * @param timeout Timeout to wait. * @return {@code True} if successfully waited, {@code false} if timeout happened. * @throws InterruptedException If thread is interrupted. */ public synchronized boolean awaitEvents(int cnt, long timeout) throws InterruptedException { long start = U.currentTimeMillis(); long now = start; while (start + timeout > now) { if (evtCnt >= cnt) return true; wait(start + timeout - now); now = U.currentTimeMillis(); } return false; }