python如何使用多线程_Python 类中的方法如何多线程调用?
這么寫直接彈框報(bào)python運(yùn)行出錯(cuò),/尷尬,那這個(gè)怎么多線程調(diào)用getA/getB/getC/getD/getE呢?每次傳參還要循環(huán)個(gè)arg2list列表
class ThreadTest():
def __init__(self):
pass
def getA(self, args1, args2):
pass
def getB(self, args1, args2):
pass
def getC(self, args1, args2):
pass
def getD(self, args1, args2):
pass
def getE(self, args2):
pass
if __name__ == "__main__":
Test = ThreadTest()
args2list = ['table1','table2']
args1 = 2
thread_ = []
for args2 in args2list:
t1 = threading.Thread(target=Test.getA, args = (args1, args2))
t2 = threading.Thread(target=Test.getB, args = (args1, args2))
t3 = threading.Thread(target=Test.getE, args = (args2))
t4 = threading.Thread(target=Test.getC, args = (args1, args2))
t5 = threading.Thread(target=Test.getrace, args = (args1, args2))
thread_.append(t1)
thread_.append(t2)
thread_.append(t3)
thread_.append(t4)
thread_.append(t5)
print(thread_)
for t in thread_:
t.setDaemon(True)
t.start()
t.join()
總結(jié)
以上是生活随笔為你收集整理的python如何使用多线程_Python 类中的方法如何多线程调用?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 左旋肉碱减肥副作用
- 下一篇: 减肥一天摄入多少热量