python 进程,,import osi
python 进程,,import osi
import osimport timeret = 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 osimport timeret = os.fork()if ret ==0: print(‘......1......‘)else: print(‘......2......‘)ret = os.fork()if ret ==0: print(‘......11......‘)else: print(‘......22.....‘)
import osimport timeret = os.fork()if ret ==0: print(‘......1......‘)else: print(‘......2......‘) ret = os.fork() if ret ==0: print(‘......11......‘) else: print(‘......22.....‘)
python 进程
评论关闭