标签:auth min author mamicode 进程间通信 png 通过 图片 image
#_author:来童星
#date:2019/12/17
#通过队列实现进程间通信
from multiprocessing import Process
def plus():
print(‘--------子进程1开始---------‘)
global g_num
g_num+=50
print(‘g_num is %d‘%g_num)
print(‘--------子进程1结束---------‘)
def minus():
print(‘--------子进程2开始---------‘)
global g_num
g_num -= 50
print(‘g_num is %d‘ % g_num)
print(‘--------子进程2结束---------‘)
g_num=100
if __name__==‘__main__‘:
print(‘--------主进程开始---------‘)
print(‘g_num is %d‘ % g_num)
p1=Process(target=plus)
p2=Process(target=minus)
p1.start()
p2.start()
p1.join()
p2.join()
print(‘--------主进程结束---------‘)
标签:auth min author mamicode 进程间通信 png 通过 图片 image
原文地址:https://www.cnblogs.com/startl/p/12054243.html