|
本帖最后由 mandrake 于 2020-5-28 22:32 编辑
我将excel二维表格读入列表alist中,列表的每一个元素也是一个列表,包含一行的所有列的数据。
假设excel表格1000行,也就是说alist列表有1000个元素。 我在10个线程中,每个线程严格指定访问(读写)的列表范围。
请问,这种方式对alist列表的并发写入,会不会造成数据写入的冲突?
比如:
- def myprocess(startno,endno):
- global alist
- while True:
- for i in range(startno,endno+1)
- alist[i][0]= ...........
- alist[i][1] = ...........
- if __name__ ='__main__':
- alist =[]
- # 从excel文件中读取数据到alist列表 (略)
- p1 = threading.Thread(target=myprocess,args=(0,99))
- p2 = threading.Thread(target=myprocess,args=(100,199))
- p3 = threading.Thread(target=myprocess,args=(200,299))
- ...........
- p1.start()
- p2.start()
- p3.start()
- ...........
复制代码
|
|