我目前正在创建一个python脚本,它将遍历从列表中接收到的数组(使用readline()),然后使用python线程一次遍历这十个。到目前为止,我已经尝试了几种选择
for num in numbers:,然后使用另一个for循环for i in range(10):创建10个线程。这种方法不起作用,因为它刚刚创建了10个线程for card in cards:
threads = []
card = card.strip()
for i in range(10):
x = threading.Thread(target=testFunct, args=(card,))
threads.append(x)
x.start()
for thread in threads:
thread.join()任何帮助都是非常感谢的。我真的不知道该怎么做。我在想,我可能需要一些类似线程池的东西,但我不确定这到底是如何工作的。
发布于 2020-12-05 22:01:47
for card in cards:
threads = []
card = card.strip()
for i in range(10):
x = threading.Thread(target=testFunct, args=(card,))
threads.append(x)
x.start()
for thread in threads:
thread.join()@DanielFarina的答复
https://stackoverflow.com/questions/65162097
复制相似问题