previous | start | next

## Object Locks

- Each implicit lock has one associated (anonymous) condition object
- `Object.wait` blocks current thread and adds it to wait set
- `Object.notifyAll` unblocks waiting threads

      public synchronized void add(E newValue)
         throws InterruptedException
      {
         while (size == elements.length) wait();
         elements[tail] = anObject;
         . . .
         notifyAll(); // notifies threads waiting to remove elements
      }

- Ch9/queue3/BoundedQueue.java

previous | start | next