# L-35 MCS 260 Fri 8 Apr 2016 : 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")
