title: A simple way to run a piece of python code in parallel?
body: <p>I have this very simple python code:</p>
  
  <pre><code>Test = 1;
  
  def para():
     while(True):
        if Test &gt; 10:
           print("Test is bigger than ten");
        time.sleep(1);
  
  para(); # I want this to start in parallel, so that the code below keeps executing without waiting for this function to finish
  
  while(True):
     Test = random.randint(1,42);
     time.sleep(1);
  
     if Test == 42:
         break;
  
  ...#stop the parallel execution of the para() here (kill it)
  
  ..some other code here
  </code></pre>
  
  <p>Basically, I want to run the function para() in parallel to the other code, so that the code below it doesn't have to wait for the para() to end.
  However, I want to be able to access the current value of the Test variable, inside of the para() while it is running in parallel (as seen in the code example above). Later, when I decide, that I am done with the para() running in parallel, I would like to know how to kill it both from the main thread, but also from within the parallel-ly  running para() itself (self-terminate).</p>
  
  <p>I have read some tutorials on threading, but almost every tutorial approaches it differently, plus I had a trouble understanding some of it, so I would like to know, what is the easiest way to run a piece of code in parallel.</p>
  
  <p>Thank you.</p>