前导理论知识见:python并发编程&多线程(一)


 

一 threading模块介绍

multiprocess模块的完全模仿了threading模块的接口,二者在使用层面,有很大的相似性

官网链接:https://docs.python.org/3/library/threading.html?highlight=threading#(装B模式加载中…………)

 

二 开启线程的两种方式

#方式一
from threading import Thread
import time
def sayhi(name):
    time.sleep(2)
    print('%s say hello' %name)

if __name__ == '__main__':
    t=Thread(target=sayhi,args=('egon',))
    t.start()
    print('主线程')
方法一

相关文章:

  • 2021-05-03
  • 2022-01-03
  • 2021-12-08
  • 2021-06-03
猜你喜欢
  • 2022-01-13
  • 2021-06-29
  • 2021-06-09
  • 2021-04-12
  • 2021-12-04
  • 2021-12-04
  • 2021-12-04
相关资源
相似解决方案