title: How can I make this multithreaded?
body: <p>I made a Python script that simulates a dice and then calculates the relative frequency.</p>
  <p>I thought, why not making it multithreaded? Now I'm stuck with the variables. If I run this, it's like the last thread overrides all other results, so it will run multithreaded but only the result of the last thread's taken. Modify the variable tries to your needs, it's set to 8 so you see that there were only 2 random numbers taken and calculated to percent at the end. Don't modify NrThreads, because it always starts 4.</p>
  <pre><code>import threading
  import random
  
  
  ### CONFIGURE
  tries=8
  NrThreads=4
  triesThread=round(round(tries)/4)
  ###\CONFIGURE
  
  def ThreadCode():
      global one
      global two
      global three
      global four
      global five
      global six
      one=0
      two=0
      three=0
      four=0
      five=0
      six=0
      for i in range(0, triesThread):
          number=random.randint(1,6)
          if (number == 1):
              one=one+1
          if (number == 2):
              two=two+1
          if (number == 3):
              three=three+1
          if (number == 4):
              four=four+1
          if (number == 5):
              five=five+1
          if (number == 6):
              six=six+1
  
  thread1 = threading.Thread(target=ThreadCode)
  thread1.start()
  print(&quot;Started thread&quot;)
  thread2 = threading.Thread(target=ThreadCode)
  thread2.start()
  print(&quot;Started thread&quot;)
  thread3 = threading.Thread(target=ThreadCode)
  thread3.start()
  print(&quot;Started thread&quot;)
  thread4 = threading.Thread(target=ThreadCode)
  thread4.start()
  print(&quot;Started thread&quot;)
  thread1.join()
  thread2.join()
  thread3.join()
  thread4.join()
  
  print(&quot;Number 1: &quot;, one)
  print(&quot;Number 2: &quot;, two)
  print(&quot;Number 3: &quot;, three)
  print(&quot;Number 4: &quot;, four)
  print(&quot;Number 5: &quot;, five)
  print(&quot;Number 6: &quot;, six)
  
  p1=one/tries
  print(&quot;Probability for number 1: &quot;, p1)
  
  for i in ([one, two, three, four, five, six]):
      print(i/tries,&quot;  &quot;, i/tries*100,&quot;%&quot;)
  </code></pre>