title: How to handle this (db) queue race condition?
body: <p>Basically i have multi threads that adds data into a queue via SQLite. I have another one thread that pulls them and process them one at a time (too much resource to do multiple at once). The processing thread does this:</p>
  
  <ol>
  <li>pull data from DB</li>
  <li>foreach { proccess }</li>
  <li>if count == 0 { thread.suspend() } (waken by thread.resume())</li>
  <li>repeat</li>
  </ol>
  
  <p>my worker thread does:</p>
  
  <ol>
  <li>Validates data</li>
  <li>Inserts into DB</li>
  <li>call Queue.Poke(QueueName)</li>
  </ol>
  
  <p>When I poke it, if the thread is suspended I <code>.resume()</code> it.</p>
  
  <p>What I am worried about is if the process thread sees <code>count==0</code>, my worker inserts and pokes then my process continues down the if and sleeps. It won't realize there is something new in the DB.</p>
  
  <p>How should I write this in such a way that I won't have a race condition.</p>