求教大神,电脑上运行没问题,ipad上出错
pythonista吧
全部回复
仅看楼主
level 5
求教大神,电脑上运行没问题,ipad上出错
2018年11月29日 14点11分 1
level 5
补上原图
2018年11月29日 23点11分 2
level 5
#多进程
#与多线程相比,多进程就是import multiprocessing 然后替换相应的方法multiprocessing.Process()
from time import ctime,sleep
import multiprocessing
def talk(content,loop):
for i in range(loop):
print("Start talk %s %s" %(content,ctime()))
sleep(3)
def write(content,loop):
for i in range(loop):
print("Start write %s %s" %(content,ctime()))
sleep(5)
process=[]
p1=multiprocessing.Process(target=talk,args=('Speek:Hello,51zxw',2))
process.append(p1)
p2=multiprocessing.Process(target=write,args=('Write:Life is short you need Python!',2))
process.append(p2)
if __name__=="__main__":
for p in process:
p.start()
for p in process:
p.join() #join() 线程守护
print("All Process end %r" %ctime())
#相关延申
#·进程间通信IPC(Interprocess communication)
#·线程锁,进程锁
#·生命周期
#·进程调度
2018年12月01日 09点12分 3
1