Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change the name of thread in thread pool
Qt 6.11 is out! See what's new in the release blog

How to change the name of thread in thread pool

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MihanM Offline
    MihanM Offline
    Mihan
    wrote on last edited by Mihan
    #1

    Hi all

    I want to change the name of the thread run in the global thread pool. But I know we could only change it by setobjectName() before the thread started.

    Now I have some ways to create threads:

    1. QThreadPool::globalInstance()->start()
    2. QtConcurrent::run()

    So is there any other way to change that?

    BTW, I know QThread but I don't want to move a function to be a class, also it will not be transfered frequently.

    Best regards
    Mihan

    J.HilkJ 1 Reply Last reply
    0
    • MihanM Mihan

      Hi all

      I want to change the name of the thread run in the global thread pool. But I know we could only change it by setobjectName() before the thread started.

      Now I have some ways to create threads:

      1. QThreadPool::globalInstance()->start()
      2. QtConcurrent::run()

      So is there any other way to change that?

      BTW, I know QThread but I don't want to move a function to be a class, also it will not be transfered frequently.

      Best regards
      Mihan

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Mihan what exactly do you want to do?

      "Thread names" I only know from Java, not c++.


      Well, there's also this
      https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2022

      But I don't think that is covered by the Qt API, seems like a very OS specific use case.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • MihanM Mihan has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved