Python笔记
🗒️多线程编程
00 分钟
2021-7-2
2023-12-30
type
status
date
slug
summary
tags
category
icon
学习进度
  • Thread对象就我们创建多线程中的一个线程,通过start让线程去工作,工作的内容是由target这个参数来指定它的工作,想让它做什么工作就把工作封装到一个函数里面,然后把函数名作为target,然后就可以得到执行这个函数的线程了,
  • threading模块的使用:thread_obj=threading.Thread(target=func)创建线程对象
  • thread_obj.start()启动线程执行。
notion image
  • 两种方式都可以向它们传递参数,(注意:元组只有一个时要带逗号)
notion image
  • 如果没有whine true无限循环,它只会运行一次就停止。
notion image