#!/usr/bin/python
import threading
import time
# this is the function we are using for thread creation
def func(ThreadName,delay):
print("%s started its execution now"%(ThreadName))
count=0
while count<5:
count=count+1
print("Iteration no : %d"%int(count)+" Name :%s"%ThreadName +" Time :%s"%(time.ctime(time.time())))
time.sleep(delay)
print("------------- %s has now finished executing ---------------"%ThreadName)
# now we have to start threads that use this func() method
t1=threading.Thread(target=func,args=("FIRST THREAD",3))
t2=threading.Thread(target=func,args=("SECOND THREAD",5))
t1.start()
t2.start()
t1.join()
t2.join()
print(" ****************** All the tasks have finished executing *******************************")
while True:
pass