# L-27 MCS 275 Mon 17 Mar 2008 : 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"
