programming_tutorials/wip/06_other_languages/python/thread_class.py

20 lines
382 B
Python

import threading
import time
class MyThread(threading.Thread):
def __init__(self, threadID, name):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
def run(self):
print("t: " + self.name + " " + str(self.threadID))
th1 = MyThread(1, "t1")
th2 = MyThread(2, "t2")
th1.start();
th2.start();
th1.join();
th2.join();