title: Python GIL prevent CPU usage to exceed 100% in multiple core machine?
body: <p>Many references say that, Python GIL lower down the performance of multi threading code in multi core machine, since each thread will need to acquire the GIL before executioin.</p>
  
  <p>In other words, it looks like GIL make a multi threading Python program to a single thread mode in fact.</p>
  
  <p>For example:</p>
  
  <p>(1) Thread A get GIL, execute some time, release GIL</p>
  
  <p>(2) Thread B get GIL, execute some time, release GIL</p>
  
  <p>...</p>
  
  <p>However, after some simple experiments, I found that although GIL lower down the performance, the total CPU usage may exceed 100% in multiple core machine.</p>
  
  <pre><code>from threading import Thread
  
  def test():
      while 1:
          pass
  
  for i in range(4):
      t = Thread(target=test)
      t.start()
  </code></pre>
  
  <p>On a 4 core, 8 thread machine, the above program will occupy around 160% CPU usage.
  Is there anything I misunderstand? Two threads can execute <strong>exactly at the same moment</strong>? Or the <strong>CPU usage calculation</strong> has bias or something wrong?</p>
  
  <p>Thanks</p>