Python教程

python线程池传参demo

本文主要是介绍python线程池传参demo,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import threadpool

def hello(name):
    for i in range(0,5):
        print(name+str(i))

if __name__ == "__main__":

    # print(hello("test"))
    val_pool=[]
    for i in range(0,2):
        var_dict={"name":"test"+str(i)}
        var_tup=(None,var_dict)
        val_pool.append(var_tup)

    print(val_pool)
    pool=threadpool.ThreadPool(10)
    requests = threadpool.makeRequests(hello, val_pool)
    for req in requests:
        pool.putRequest(req)

    pool.wait()

 

这篇关于python线程池传参demo的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!