#!/usr/bin/python
import threading
import time
exitFlag = 0
[docs]class myThread (threading.Thread):
def __init__(self, threadID, name, counter):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
[docs] def run(self):
print( "Starting " + self.name)
print_time(self.name, self.counter, 5)
print("Exiting " + self.name)
[docs]def print_time(threadName, delay, counter):
while counter:
if exitFlag:
threadName.exit()
time.sleep(delay)
print("%s: %s" % (threadName, time.ctime(time.time())))
counter -= 1