title: How to ping a range of IP addresses using multithreading
body: <p>Lets say that I have the following ip range "10.0.0.x". I need to loop on this range of ips - "10.0.0.1-255", ping each one, and check the response.  </p>
  
  <p>This is my code:  </p>
  
  <pre><code>for ip in range(1, 256):
    fullIP = '10.0.0' + ip
    if(Ping(fullIP) == True):
      print(fullIP + ' responded')
    else:
      print(fullIP + ' did not respond')
  </code></pre>
  
  <p>This code works but unfortunately it is very slow.<br>
  I would like to make it more efficient through multi threading so i did the following:  </p>
  
  <pre><code>def PingRange(start, end):
    for ip in range(start, end):
    fullIP = '10.0.0' + ip
    if(Ping(fullIP) == True):
      print(fullIP + ' responded')
    else:
      print(fullIP + ' did not respond')
  
  try:
    thread.start_new_thread( PingRange, (1, 123))
    thread.start_new_thread( PingRange, (123, 256))
  except:
    print "Error: unable to start thread"
  </code></pre>
  
  <p>This code also works, but it could work better and more universal.<br>
  If this code was written properly then I wouldn't just constantly create two threads; I would create as many threads as the operating system would allow me.<br>
  Some computers allow 8 threads, others allow only 4, and some don't even allow threading.  </p>
  
  <p>How can I make this program use the maximum amount of threads in Python?</p>