Networking Forum

Thread

  Satheesh Kumar S        05/Dec/2016

#from threading import Thread


import time


import threading


 


def timer(name,delay,repeat):


    print(" timer ",name," started12121")


    while repeat > 0:


        time.sleep(delay)


        print(" ",name,time.ctime())


        repeat-=1


    print(" timer ",name,"compleated")


def main():


    t1=threading.Thread(target=timer,args=("time1",1,5))


    t2=threading.Thread(target=timer,args=("timer2",3,5))


    t1.start()


    time.sleep(2)


    t2.start()


    print(" main compleated")


 


if __name__ == '__main__':


main()