<分区> 分区>
如何在以下代码中将打开线程的最大值限制为 20?我知道过去曾问过一些类似的问题,但我特别想知道如何最好地使用 Queue 并在可能的情况下使用工作示例。
# b is a list with 10000 items
threads = [threading.Thread(target=targetFunction, args=(ptf,anotherarg)) for ptf in b]
for thread in threads:
thread.start()
for thread in threads:
thread.join()
