title: Number of active threads
body: <p>Python version: '2.7.3 (default, Apr 10 2013, 06:20:15) \n[GCC 4.6.3]'</p>
  
  <p>I have this:</p>
  
  <pre><code>#!/usr/bin/env python
  import time, threading, os
  def f1(arg1):
      for i in xrange(arg1):
          time.sleep(1)
          print "i is: ", i
          print threading.active_count()
          print threading.enumerate()
  
  if __name__ == '__main__':
  
      t = threading.Thread(name="MyThread1", target=f1, args=(5,))
      t.start()
  </code></pre>
  
  <p>My question is, why is the number of active threads being reported as 2 and why does the list generated by <code>enumerate</code> contain the main thread as well.</p>
  
  <p>I was thinking that the main thread terminates after spawning "MyThread1".</p>
  
  <p>$ ./threadeg.py</p>
  
  <pre><code>i is:  0
  2
  [&lt;_MainThread(MainThread, stopped 139858183157504)&gt;, &lt;Thread(MyThread1, started 139858153768704)&gt;]
  
  i is:  1
  2
  [&lt;_MainThread(MainThread, stopped 139858183157504)&gt;, &lt;Thread(MyThread1, started 139858153768704)&gt;]
  
  i is:  2
  2
  [&lt;_MainThread(MainThread, stopped 139858183157504)&gt;, &lt;Thread(MyThread1, started 139858153768704)&gt;]
  
  i is:  3
  2
  [&lt;_MainThread(MainThread, stopped 139858183157504)&gt;, &lt;Thread(MyThread1, started 139858153768704)&gt;]
  
  i is:  4
  2
  [&lt;_MainThread(MainThread, stopped 139858183157504)&gt;, &lt;Thread(MyThread1, started 139858153768704)&gt;]
  </code></pre>