【发布时间】:2019-11-27 13:07:40
【问题描述】:
假设我想在文件的每一行中处理彼此不依赖的字符串。我通常是怎么做的:
def process_line(filelines, i):
#process lines
import threading
threads = []
lines = open(file).readlines()
for i in range(0,len(lines)):
threads.append(threading.Thread(target=process_line, args=(lines,i,))
[t.start() for t in threads]
[t.join() for t in threads]
【问题讨论】:
标签: python multithreading pool