- 多线程demo
from threading import Thread
class MyThread(Thread):
def __init__(self, func):
Thread.__init__(self)
self.func = func
def run(self):
self.func()
def sayhello():
print('hello')
if __name__ == '__main__':
for i in range(3):
t = MyThread(sayhello)
t.start()