void (ProgressIndicator pi) { if (pi.isShowing()) { final long maxWait = 3000; final long start = System.currentTimeMillis(); while ((!pi.isPopupWasShown()) && (pi.isRunning()) && (System.currentTimeMillis() - maxWait < start)) { final Object lock = new Object(); //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (lock) { try { lock.wait(100); } catch (InterruptedException e) { // } } } ProgressManager.checkCanceled(); } }