title: Python Threading: Running 2 different functions simultaneously
body: <p>I have a function <code>foo</code> that only stops once a condition has been met. While <code>foo</code> is running, I need to ask for user input the whole time (keeps asking for user input). I want them to run separately without interfering with each other. </p>
  
  <p>In my example below, <code>foo</code> keeps printing 'Hello' and <code>getUserInput</code> keeps looking for user input. I want foo to keep printing hello even if i do not enter anything for user input. It will keep asking for input as long as the user does not enter letter 'e'. I have my attempt below:</p>
  
  <pre><code>import threading
  from time import sleep
  
  class test:
      def __init__(self):
          self.running = True
  
      def foo(self):
          while(self.running):
              print 'Hello\n'
              sleep(2)
  
      def getUserInput(self):
          x = ''
          while(x != 'e'):
              x = raw_input('Enter value: ')
          self.running = False
  
      def go(self):
          th1 = threading.Thread(target=self.foo)
          th2 = threading.Thread(target=self.getUserInput)
          th1.start()
          th2.start()
  
  
  t = test()
  t.go()
  </code></pre>
  
  <p>My code prints out the first hello and asks for input but nothing after that. What am I doing wrong? Thanks for your help in advance.</p>