import threading, timefrom sys import stdoutdef sleepandprint(): time.sleep(1) print "Hello from both of us."def threadcode(): stdout.write("Hello from the new thread. My name is %sn" % threading.currentThread().getName()) sleepandprint()print "Before starting a new thread, my name is", threading.currentThread().getName()t = threading.Thread(target = threadcode, name = "ChildThread")t.setDaemon(1)t.start()stdout.write("Hello from the main thread. My name is %sn" % threading.currentThread().getName())sleepandprint()t.join()
Name (required)
email (will not be published) (required)
Website