from multiprocessing import Process
import time

def task(name):
print("%s start" % name)
time.sleep(3)
print("%s stop" % name)

if __name__ == '__main__':

p = Process(target=task,args=("jerry",))
p.start()
print("我是主进程!!!")
time.sleep(100)
print("我是主进程!!! over")

 

# 主进程一定是先是
# 一旦启动子进程 后续的代码就并发 没有先后顺序
# 如果父进程需要等待子进程结束后才能执行

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-03-12
  • 2021-08-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案