private static void waitUntilReady() { synchronized (readyLock) { while (readyCnt < nCouples) { try { readyLock.wait(); } catch (InterruptedException ie) { ie.printStackTrace(); } } } }
private static void notifyReady() { synchronized (semaphore) { synchronized (readyLock) { readyCnt++; readyLock.notifyAll(); } try { semaphore.wait(); } catch (InterruptedException ie) { ie.printStackTrace(); } } }