Java BlockingQueue take vs poll
<p>I'm running a process where:</p>

<ul>
<li>If there's an item in the queue, the item should be processed.</li>
<li>There should be at least one item processed every 5 minutes. If there isn't, a dummy item is added.</li>
</ul>

<p>I'm thinking of using a BlockingQueue to accomplish this - it offers the functions <code>take()</code> and <code>poll(timeout, timeunit)</code> to do this.</p>

<p>With <code>take</code> I would simply have a <code>while(item = queue.take()){ process(item); }</code>. There would be a second thread running that would add a dummy item to the queue every 5 minutes, so that every 5 minutes it is guaranteed that at least this one dummy item is processed.</p>

<p>With <code>poll</code> I would do</p>

<pre><code>while(true){
    item = queue.poll(5L, TimeUnit.MINUTES);
    if(item == null) item = 'dummyitem';
    process(item);
}
</code></pre>

<p>Is there a difference between these approaches, which one is better?</p>