import multiprocessing
data_list = []
def task(arg):
data_list.append(arg)
print(data_list)
def run():
for i in range(10):
p = multiprocessing.Process(target=task, args=(i,))
p.start()
if __name__ == '__main__':
run()
'''
打印结果:
[0]
[2]
[3]
[1]
[4]
[6]
[5]
[8]
[7]
[9]
'''
原文地址:https://www.cnblogs.com/apollo1616/p/10351460.html
时间: 2024-09-28 09:39:03