private void lockOnReportDir(File reportDir) { synchronized (files) { while (files.contains(reportDir)) try { files.wait(); } catch (InterruptedException ex) { logger.log(SEVERE, Thread.currentThread().getName() + " INTERRUPTED", ex); } files.add(reportDir); files.notifyAll(); // must own the lock } }