public synchronized void deposit(double value) {
   while (count == numSlots)
      try {
         wait();
      } catch (InterruptedException e) {}
   buffer[putIn] = value;
   putIn = (putIn + 1) % numSlots;
   count++;
   if (count == 1)
       notifyAll();
}

public synchronized double fetch() {
   double value;
   while (count == 0)
      try {
         wait();
      } catch (InterruptedException e) {}
   value = buffer[takeOut];
   takeOut = (takeOut + 1) % numSlots;
   count--;
   if (count == numSlots-1)
      notifyAll();
   return value;
}
