进程之间不共享资源的原因
import multiprocessing
import time
g_list = list()
def add_list():
for i in range(1, 5):
g_list.append(i)
time.sleep(0.2)
print(i)
pass
pass
def read_list():
print(g_list)
if __name__ == '__main__':
add_process = multiprocessing.Process(target=add_list)
read_process = multiprocessing.Process(target=read_list)
add_process.start()
# join 是当前进程下(主进程),只有当子进程执行完成之后,才得以往下执行
add_process.join()
read_process.start()
print(g_list)