# L-30 MCS 275 Mon 29 Mar 2010 : hello_threads.py # Illustration on the use of the thread module. import thread import time def say_hello(name,n): "says hello and sleeps n seconds" print "hello from " + name time.sleep(n) print name + " slept %d seconds" % n print "starting three threads" thread.start_new_thread(say_hello,("1st thread",3)) thread.start_new_thread(say_hello,("2nd thread",2)) thread.start_new_thread(say_hello,("3rd thread",1)) time.sleep(4) # we must wait for all to finish! print "done running the threads"