title: Python multithreading list append gives unexpected results
body: <p>I want to test if it's ok to append to list from two threads, but I'm getting messy output:</p>
  
  <pre><code>import threading
  
  
  class myThread(threading.Thread):
      def __init__(self, name, alist):
          threading.Thread.__init__(self)
          self.alist = alist
  
      def run(self):
          print "Starting " + self.name
          append_to_list(self.alist, 2)
          print "Exiting " + self.name
          print self.alist
  
  
  def append_to_list(alist, counter):
      while counter:
          alist.append(alist[-1]+1)
          counter -= 1
  
  alist = [1, 2]
  # Create new threads
  thread1 = myThread("Thread-1", alist)
  thread2 = myThread("Thread-2", alist)
  
  # Start new Threads
  thread1.start()
  thread2.start()
  
  print "Exiting Main Thread"
  print alist
  </code></pre>
  
  <p>So the output is:</p>
  
  <pre><code>Starting Thread-1
  Exiting Thread-1
   Starting Thread-2
   Exiting Main Thread
  Exiting Thread-2
  [1[1, 2[, 1, 2, 23, , 34, 5, 6, ]4
  , 5, , 3, 64, 5, ]6]
  </code></pre>
  
  <p>Why it's so messy and alist not equal to [1,2,3,4,5,6]?</p>