title: Python Threads 'While' not Behaving
body: <p>Okay. So I'm trying to make 2 threads to run and increment a value so it knows when to stop. I'm kind of lost, because I'm new to Python, and everything looks right to me..<br /></p>
  
  <pre><code>import threading;
  import socket;
  import time;
  
  count = 0;
  
  class inp(threading.Thread):
      def run(self):
          while count &lt; 11:
              time.sleep(0.5);
              print("Thread 1!");
              count += 1;
  
  class recv_oup(threading.Thread):
      def run(self):
          while count &lt; 31:
              time.sleep(0.5);
              print("Thread 2!");
              count += 1;
  
  inp().start();
  recv_oup().start();
  </code></pre>
  
  <p>And the error is quite long...<br /></p>
  
  <pre><code>Exception in thread Thread-1:
  Traceback (most recent call last):
    File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
      self.run()
    File "core.py", line 9, in run
      while count &lt; 11:
  UnboundLocalError: local variable 'count' referenced before assignment
  
  Exception in thread Thread-2:
  Traceback (most recent call last):
    File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
      self.run()
    File "core.py", line 16, in run
      while count &lt; 31:
  UnboundLocalError: local variable 'count' referenced before assignment
  </code></pre>
  
  <p>I have no clue what's happening. As I said, new to Python, so this is all gibberish to me. Any help is greatly appreciated</p>