title: Communicate data between threads in python
body: <p>I am new to python I have very little knowledge about threads in python. Here is my sample code.</p>
  <pre><code>import threading
  from threading import Thread
  import time
  
  check = False
  
  def func1():
      print (&quot;funn1 started&quot;)
      while check:
          print (&quot;got permission&quot;)
  
  def func2():
      global check
      print (&quot;func2 started&quot;)
      time.sleep(2)
      check = True
      time.sleep(2)
      check = False
  
  if __name__ == '__main__':
      Thread(target = func1).start()
      Thread(target = func2).start()
  </code></pre>
  <p>What I want is to see see &quot;got permission&quot; as the output. But with my current code it is not happening. I assume that the <code>func1</code> thread is closed before <code>func2</code> changes the <code>check</code> value to <code>True</code>.</p>
  <p>How can I keep <code>func1</code> alive?
  I have researched on the internet but I could not found a solution.
  Any help would be appreciated.
  Thank you in advance!</p>