title: Java LinkedBlockingQueue with ability to signal when done?
body: <p>I have a situation of a single producer and single consumer working with a queue of objects. There are two situations when the queue might be empty:</p>
  
  <ol>
  <li>The consumer handled the objects quicker than the producer was capable of generating new objects (producer uses I/O before generating objects).</li>
  <li>The producer is done generating objects.</li>
  </ol>
  
  <p>If the queue is empty, I want the consumer to wait until a new object is available or until the producer signals that it is done.</p>
  
  <p>My research so far got me no where because I still ended up with a loop that checks both the queue and a separate boolean flag (isDone). Given that there's no way of waiting on multiple locks (thought of waiting on the queue AND the flag), what can be done to solve this?</p>