document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/usr/bin/python
  2. import threading
  3. import time
  4. # this is the function we are using for thread creation
  5. def func(ThreadName,delay):
  6.     print("%s started its execution now"%(ThreadName))
  7.     count=0
  8.     while count<5:
  9.         count=count+1
  10.         print("Iteration no : %d"%int(count)+" Name :%s"%ThreadName +" Time :%s"%(time.ctime(time.time())))
  11.         time.sleep(delay)
  12.  
  13.     print("------------- %s has now finished executing ---------------"%ThreadName)
  14.  
  15.  
  16.  
  17. # now we have to start threads that use this func() method
  18.  
  19. t1=threading.Thread(target=func,args=("FIRST THREAD",3))
  20. t2=threading.Thread(target=func,args=("SECOND THREAD",5))
  21. t1.start()
  22. t2.start()
  23. t1.join()
  24. t2.join()
  25.  
  26. print(" ******************  All the tasks have finished executing *******************************")
  27.  
  28. while True:
  29.     pass
');