简单模拟进程(multiprocessing)

工具:Windows10,pyhton3.6,pycharm2017.2.4专业版
#导入类库
import time
import  multiprocessing
#模拟进程1
def test1():
    while True:
        print('1_______')
        time.sleep(1)
#模拟进程2
def test2():
    while True:
        print('2_______')
        time.sleep(1)
#设置启动进程
def main():
    p1 = multiprocessing.Process(target=test1)
    p2 = multiprocessing.Process(target=test2)
    p1.start()
    p2.start()
#启动进程
if __name__=='__main__':
    main()
运行结果
运行结果题

猜你喜欢

转载自blog.csdn.net/weixin_43160039/article/details/82632406
今日推荐