from multiprocessing.dummy import Pool as ThreadPool
pool = ThreadPool(4)
results = pool.map(my_function, my_array)
传入多个参数的情况:
results = pool.starmap(function, zip(list_a, list_b))
参数是一个常量和数组:
results = pool.starmap(function, zip(itertools.repeat(constant), list_a))
参考:
How to use threading in Python?
A Better Model for Day to Day Threading Tasks