【发布时间】:2017-11-09 00:47:17
【问题描述】:
我有一个数组,例如 100 个项目,我想为我的数组的每 10 个项目运行 10 个线程。
我的问题是我不知道如何使用 for 循环为前 10 个项目、第二个 10 项目等运行 10 个线程。
我需要的如下:
for item in myarray:
thread.start_new_thread(first_item)
thread.start_new_thread(second_item)
thread.start_new_thread(third_item)
thread.start_new_thread(fourth_item)
thread.start_new_thread(fifth_item)
thread.start_new_thread(sixth_item)
thread.start_new_thread(seventh_item)
thread.start_new_thread(eight_item)
thread.start_new_thread(ninth_item)
thread.start_new_thread(tenth_item)
对于我的 for 循环的第二轮,为后十个项目运行线程。
如何每次将我的 for 循环索引增加十次?
【问题讨论】:
标签: python arrays multithreading for-loop