void () { assert myControlled != null; final long start = System.currentTimeMillis(); synchronized (myLock) { while (true) { try { myLock.wait(300); } catch (InterruptedException e) { // } if ((System.currentTimeMillis() - start) >= ourTimeout) { myExitedByTimeout = true; return; } if (Boolean.TRUE.equals(myControlled.get())) return; } } }