标签:http images 技术分享 子进程 fork style import 创建 sleep
import os import time ret = os.fork() # 创建子线程 if ret ==0: # 子进程中返回值为0,父进程>0 while True: print(‘......1......‘) time.sleep(1) else: while True: print(‘......2......‘) time.sleep(1)
多fork问题,以下代码会出现4个进程
import os import time ret = os.fork() if ret ==0: print(‘......1......‘) else: print(‘......2......‘) ret = os.fork() if ret ==0: print(‘......11......‘) else: print(‘......22.....‘)
import os import time ret = os.fork() if ret ==0: print(‘......1......‘) else: print(‘......2......‘) ret = os.fork() if ret ==0: print(‘......11......‘) else: print(‘......22.....‘)
标签:http images 技术分享 子进程 fork style import 创建 sleep
原文地址:http://www.cnblogs.com/Erick-L/p/7135859.html