void (Semaphore semaphore) { TestTimeOut t = TestTimeOut.setTimeout(TIMEOUT_MS, TimeUnit.MILLISECONDS); while (!t.timedOut()) { if (semaphore.waitFor(1)) return; UIUtil.dispatchAllInvocationEvents(); } fail("Timeout"); }