title: How to run two threads simultaneously while sharing their values?
body: <p>I need to run two threads. The first one is a sensor, the second one is motor. 
  I need to run those two threads in parallel with two different delay times and I need to communicate between them. This is my try code. here the motor thread runs only once and print </p>
  
  <p>This is the code  </p>
  
  <pre><code>from queue import Queue
  from threading import Thread
  import time
  
  def sensor(numbers,q):
      for n in numbers:
          q.put(n*n)
          print (n*n)
          time.sleep(1)  # Add some delay here
  
  def motor():
      a=q.get()
      if (a&lt;10):
          print("good")
          time.sleep(2)  # Add some delay here
      else:
          print ("bad")
          time.sleep(2)  # Add some delay here
  
  
  if __name__=="__main__":
      numbers = [1,2,3,4,5,6,7,8]
      q= Queue()
  
      p= Thread(target=sensor , args = (numbers,q))
      r= Thread(target = motor)
      p.start()
      r.start() 
  </code></pre>
  
  <p>`
  this is the results i got </p>
  
  <pre><code>1
  good
  4
  9
  16
  25
  36
  49
  64
  </code></pre>
  
  <p>i need to get good or bad comment after each number. </p>