4.22作业

进程创建的两种方式

# from multiprocessing import Process
# import time
#
# def task(name):
#     print('%s is runnning'%name)
#     time.sleep(3)
#     print('%s is over'%name)
#
# if __name__ == '__main__':
#     p=Process(target=task,args=('cyp',))
#     p.start()
#     print('主')



from multiprocessing import Process
import time

class Myprocess(Process):
    def run(self):
        print(111)
        time.sleep(1)
        print(222)

if __name__ == '__main__':
     p=Myprocess()
     p.start()
     print('主')
posted @ 2020-04-23 08:28  Python-feng  阅读(92)  评论(0编辑  收藏  举报