Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import threading
- import time
- exitFlag = 0
- class myThread (threading.Thread):
- def __init__(self, threadID, name, counter):
- threading.Thread.__init__(self)
- self.threadID = threadID
- self.name = name
- self.counter = counter
- def run(self):
- print ("Starting " + self.name)
- print_time(self.name, self.counter, 5)
- print ("Exiting " + self.name)
- 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
- myList = ['string0', 'string1', 'string2']
- def processFunc():
- count = 0
- for data in myList:
- count += 1
- mythread = myThread(count, "Thread-" + str(count), count)
- mythread.start()
- mythread.join()
- processFunc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement