Sleep in a thread : Thread : Thread PYTHON TUTORIALS


PYTHON TUTORIALS » Thread » Thread »

 

Sleep in a thread


import thread
from time import sleep, ctime

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

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

print 'starting at:', ctime()
thread.start_new_thread(loop0, ())
thread.start_new_thread(loop1, ())
sleep(6)
print 'all DONE at:', ctime()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Thread
» Thread