Loops Executed by a Single Thread : Thread « Thread « Python Tutorial






from time import sleep, ctime

def loop0():
    print 'start loop 0 at:', ctime()
    sleep(4)
    print 'loop 0 done at:', ctime()

def loop1():
    print 'start loop 1 at:', ctime()
    sleep(2)
    print 'loop 1 done at:', ctime()

print 'starting at:', ctime()
loop0()
loop1()
print 'all DONE       at:', ctime()








17.1.Thread
17.1.1.First thread example
17.1.2.Start threads to print time at different intervals
17.1.3.Loops Executed by a Single Thread
17.1.4.Sleep in a thread
17.1.5.Join threads
17.1.6.Start threads