# For an alternative version of this program see thread10a.py
import thread, time, urllib2, threading
sa = threading.Semaphore(5)
urls = ['http://www.ucc.ie', 'http://www.dkit.ie',
        'http://www.ul.ie', 'http://www.tcd.ie','http://www.ucd.ie']

def getUrlInfo(x):
    newTime = time.time()
    resp = urllib2.urlopen(x)
    sa.acquire()
    print resp.getcode()
    print 'It took ',time.time()-newTime,' seconds to get a reply from',x
    sa.release()

for y in urls:
    thread.start_new_thread(getUrlInfo, (y,))
