title: How to synchronize python threads?
body: <p>I want to synchronize two threads: one appending, another poping from the list:</p>
  
  <pre><code>import threading
  
  
  class Pop(threading.Thread):
      def __init__(self, name, alist):
          threading.Thread.__init__(self)
          self.alist = alist
          self.name = name
  
      def run(self):
          print "Starting " + self.name
          self.pop_from_alist(self.alist)
          print "Exiting " + self.name
  
      def pop_from_alist(self, alist):
          alist.pop(0)
  
  
  def main():
      alist = [1, 2]
      # Create new thread
      thread = Pop("Pop thread", alist)
      for x in range(2):
          alist.append(alist[-1]+1)
      thread.start()
      print "Exiting Main Thread"
      print alist
  main()
  </code></pre>
  
  <p>How can i do this, should I use Lock or use join methods?
  Cant find any synchronization tutorial for beginners </p>