previous | start | next

## Avoiding Deadlocks

- Use condiiton object to manage "space available" condition

      private Lock queueLock = new ReentrantLock();
      private Condition spaceAvailableCondition
         = queueLock.newCondition();

- Call `await` when condition is not fulfilled:

      public void add(E newValue)
      {
         . . .
         while (size == elements.length)
            spaceAvailableCondition.await();
         . . .
      }

previous | start | next