/** Notifies all waiting threads */ private final void atomicNotify(int index) { AtomicInteger i = auxStore.getWaiting(index); if (!i.compareAndSet(0, 0)) { synchronized (i) { i.notifyAll(); } } }
/** * Waits until a notify * * @return true if interrupted during the wait */ private final boolean atomicWait(int index) { AtomicInteger i = auxStore.getWaiting(index); i.incrementAndGet(); try { short blockId = blockIds.get(index); boolean reserved = auxStore.isReserved(blockId); synchronized (i) { if (!reserved || !auxStore.testUnstable(blockId)) { return false; } try { i.wait(); } catch (InterruptedException e) { return true; } } } finally { i.decrementAndGet(); } return false; }