【问题标题】:How to change a python thread name from inside the thread on Windows?如何从 Windows 上的线程内部更改 python 线程名称?
【发布时间】:2018-07-18 08:13:07
【问题描述】:

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

【问题讨论】:

    标签: python multithreading


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2010-10-03
      • 1970-01-01
      • 1970-01-01
      • 2011-09-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多