python - 如何从 Windows 上的线程内部更改 python 线程名称?

标签 python multithreading

我有一个主线程,它获取连接并立即生成新线程,然后在该线程内它收到一个被记录的名称,目前我的线程名为 Thread-n。我想从内部更改线程的名称。我找到了 this , 但遗憾的是它只适用于 linux,是否有类似的程序可以在 Windows 上执行此操作?

最佳答案

可以通过以下方式做到这一点:

import threading
threading.current_thread().name = "my_name"

关于python - 如何从 Windows 上的线程内部更改 python 线程名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51396841/

相关文章:

python - 何时在 python 中使用运算符重载的经验法则

python - python中的加权非负最小二乘线性回归

c++ - 单元测试线程: how to confirm that a thread was blocked

winforms - 如何从线程设置 ToolStripProgressBar 的值?

python - 查找数据中零元素的数量

python - object() 有什么用?

python - 从 Bash getenv 运行未定义

c# - 如何使用多维数组调用 Parallel.ForEach

java - 如何将参数传递给java中已经运行的线程?

c - 线程在加入之前退出