1. 进程 & 线程 & 协程

1.1. 进程

  • 进程是操作系统进行资源分配的基本单位。
  • 一个程序运行后至少有一个进程,一个进程默认有一个线程
  • import multiprocessing
    def task():
      for i in range(10):
          print("任务执行中...")
          time.sleep(0.2)
    sub_process = multiprocessing.Process(target=task, kwargs={"count": 3})
    sub_process.daemon = True
    sub_process.start()
    
Copyright © 2021 zbmain.  all right reserved,powered by Gitbook本页修订时间: 2021-03-29

results matching ""

    No results matching ""