# L-19.0 MCS 260 Wed 28 Jul 2014 : hello_threads.py

"""
Illustration on the use of the thread module.
"""

import thread
import time

def say_hello(name, nsc):
    "says hello and sleeps n seconds"
    print "hello from " + name
    time.sleep(nsc)
    print name + " slept %d seconds" % nsc

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"
