import threading
class MyThread(threading.Thread):
def __init__(self, name):
threading.Thread.__init__(self)
self.name = name
def run(self):
thread = threading.current_thread()
print(self.name)
#print('{} - start'.format(thread.name))
for d in range(9):
a = MyThread(d+1)
a.start()
this block of code print 1 to 9 sequential! I think this code didn't run well.
source https://stackoverflow.com/questions/69382296/print-digits-1-to-9-in-python-with-9-thread
Comments
Post a Comment