void () { while (true) { if (progressIndicator.isCanceled() || !progressIndicator.isRunning()) { semaphore.up(); break; } try { //noinspection SynchronizeOnThis synchronized (this) { //noinspection SynchronizeOnThis wait(2000L); } } catch (InterruptedException ignore) { } } }