title: Processing a list whilst using threading
body: <p>My code has a loop which checks a list and if there are items in the list it will process them and remove them from the list. The items are continuously inserted into the list by another thread.</p>
  
  <p>Here is the code: </p>
  
  <pre><code>while True:
      for item in list:
          Process(item)
          Remove(item)
  </code></pre>
  
  <p><strong>Problem 1:</strong> </p>
  
  <p>What I have above works but the problem is that it is very intensive on the cpu.<br>
  I can put something like 'time.sleep' in the code but this program needs to process the items in the list immediately without any delay. How do I make it less intensive on the cpu (remember that I am concurrently running another thread).</p>
  
  <p><strong>Problem 2</strong>: </p>
  
  <p>I want to stop the loop from running when the list is empty and continue to process when something is added to the list. How do I go about doing this?</p>