text: public synchronized boolean waitForGeneration(long targetGen, int maxMS) throws InterruptedException {if (targetGen > searchingGen) {reopenLock.lock();waitingGen = Math.max(waitingGen, targetGen);try {reopenCond.signal();} finally {reopenLock.unlock();}long startMS = System.nanoTime()/1000000;while (targetGen > searchingGen) {if (maxMS < 0) {wait();} else {long msLeft = (startMS + maxMS) - System.nanoTime()/1000000;if (msLeft <= 0) {return false;} else {wait(msLeft);}}}}return true;}