title: Using a global variable with a thread
body: <p>How do I share a global variable with thread?</p>
  
  <p>My Python code example is:</p>
  
  <pre><code>from threading import Thread
  import time
  a = 0  #global variable
  
  def thread1(threadname):
      #read variable "a" modify by thread 2
  
  def thread2(threadname):
      while 1:
          a += 1
          time.sleep(1)
  
  thread1 = Thread( target=thread1, args=("Thread-1", ) )
  thread2 = Thread( target=thread2, args=("Thread-2", ) )
  
  thread1.join()
  thread2.join()
  </code></pre>
  
  <p>I don't know how to get the two threads to share one variable.</p>