标签:threading port fun eth googl star RoCE python 函数
先上框架
from threading import Thread from multiprocessing import Process class MyThread(Thread): def __init__(self, func): super(MyThread,self).__init__() self.func = func def run(self): self.func() class MyProcess(Process): def __init__(self, func): super(MyProcess,self).__init__() self.func = func def run(self): self.func()
传入类的入口函数,即可实现多线程
baidu = Baidu() sogou = Sogou() google = Google() baiduThread = MyThread(baidu.run) sogouThread = MyThread(sogou.run) googleThread = MyThread(google.run) # 线程开启 baiduThread.start() sogouThread.start() googleThread.start() # 主线程等待子线程 baiduThread.join() sogouThread.join() googleThread.join()
标签:threading port fun eth googl star RoCE python 函数
原文地址:https://www.cnblogs.com/zenan/p/9188521.html