python多线程 怎么传送多个参数
1个回答
展开全部
import threadpool
import time
def Main_Def(par1, par2, par3):
print "par1 = %s, par2 = %s, par3 = %s" % (par1, par2, par3)
if __name__ == '__main__':
# 方法1
list_var1 = ['1', '2', '3']
list_var2 = ['4', '5', '6']
par_list = [(list_var1, None), (list_var2, None)]
# 方法2
# dict_var1 = {'par1': '1', 'par2': '2', 'par3': '3'}
# dict_var2 = {'par1': '4', 'par2': '5', 'par3': '6'}
# par_list = [(None, dict_var1), (None, dict_var2)]
pool = threadpool.ThreadPool(2)
requests = threadpool.makeRequests(Main_Def, par_list)
[pool.putRequest(req) for req in requests]
time.sleep(1)
pool.wait()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询