Edit, Debug and Run the given Python script files
"""In distributed systems, it is a good idea to segregate threads into groups
if they are performing different tasks. Say, for instance, you have an
application that both listens for incoming stock price changes
and also tries to predict where that price will go. You could, for instance,
have two different thread groups here: one group listening for the changes
and the other performing the necessary calculations.
"""
import threading
import time
def myThread():
print("Thread {%} starting".format(threading.currentThread().getName()))
time.sleep(10)
print("Thread {} ending".format(threading.currentThread().getName()))
for i in range(4):
threadName = "Thread-" + str(i)
thread = threading.Thread(name=threadName, target=myThread)
thread.start()
- print("{#}".format(threading.enumerate()))
Comments
Leave a comment