Ejemplo n.º 1
0
 /** Notifies all waiting threads */
 private final void atomicNotify(int index) {
   AtomicInteger i = auxStore.getWaiting(index);
   if (!i.compareAndSet(0, 0)) {
     synchronized (i) {
       i.notifyAll();
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }