title: Is it bad to use polling in Java?
body: <p>I have several <code>ArrayLists</code> which work as queues of data. Each of the queues is linked to an individual <em>thread</em> which checks if that <code>ArrayList</code> has some data in it.</p>
  
  <pre><code> while (array.size == 0) {
      // nothing
   }
  
   // do stuff with one element of the array
   // remove element from array
   // and call the loop again
  </code></pre>
  
  <p>I have done similar things in embedded system programming, but is it safe to use this in Java? The concern is about process power waste by iterating around that while loop very fast.</p>
  
  <p>It could be solved by adding <code>Thread.sleep(100)</code> and check every 100ms, but then again - slower response time.</p>
  
  <p>The question is - do I need to add that sleep or I shouldn't be concerned about that?</p>
  
  <p>Any suggestions on safer/better system to check for new data in arrays?</p>