# L-39 MCS 260 Wed 28 Nov 2007 : 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,("first thread",3)) thread.start_new_thread(say_hello,("second thread",2)) thread.start_new_thread(say_hello,("third thread",1)) time.sleep(4) # we must wait for all to finish! print "done running the threads"