PYTHON使用小结

线程使用

python 复制代码
import threading

thread01 = None

def ThreadFunc(param)
    xxxxx


def Test()
    global thread01 
    thread01 = threading.Thread(target=ThreadFunc)
    thread01.daemon = True  #设置为TRUE,主线程结束后,此线程也会退出, 默认False
    thread01.start()
    
    

也可以在创建线程时给参数

thread01 = threading.Thread(target=ThreadFunc,name="t1",daemon=True)

等待线程中止

thread01.join()

相关推荐
Want59521 分钟前
Python太极八卦图
开发语言·python
川石课堂软件测试23 分钟前
自动化测试|持续集成Git使用详解
git·python·jmeter·mysql·ci/cd·容器·kubernetes
饕餮争锋31 分钟前
python开发工具uv简介
开发语言·python·uv
znx93931 分钟前
量化交易:用理性穿越市场混沌的修行之路
人工智能·python·机器学习·期魔方
兔子零102443 分钟前
FastAPI 零基础入门教程:写过 Node.js,就能轻松学会 Python 后端开发(一)
前端·后端·python
Marst Code1 小时前
上位机开发日记 · 第 12 篇 · 测试:设备模拟器是核心资产
python
坊钰2 小时前
【LangGraph框架入门级】4. 支持联网搜索的智能代理系统
python·ai编程·langgraph
运维@小兵2 小时前
安装Pycharm并破解
ide·python·pycharm
冬、不眠的夜2 小时前
Nuitka 将 python 程序编译成 exe 指南
开发语言·python
范中勤2 小时前
Python Asyncio 协程与 LLM 异步并发原理技术文档(与 Java 对比|彻底澄清所有误区)
python·llm·协程·并发编程·asyncio