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. QTimers spawn new threads every time?

QTimers spawn new threads every time?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.9k Views
  • 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.
  • M Offline
    M Offline
    medvedm
    wrote on last edited by
    #1

    I've got a couple of QTimers that wake my code up once a second to go look for a couple of things, and I noticed that when I do so, gdb is telling me that every time I do so I'm spawning new threads. If I turn the timers off (comment them out), the thread spawning goes away, so I'm pretty sure it is the timers that are doing it...

    My gdb output looks like this:

    @
    [Thread 0xb4bfcb70 (LWP 9861) exited]
    [Thread 0xb53fdb70 (LWP 9860) exited]
    [Thread 0xb43fbb70 (LWP 9862) exited]
    [New Thread 0xb43fbb70 (LWP 9863)]
    [New Thread 0xb53fdb70 (LWP 9864)]
    [New Thread 0xb4bfcb70 (LWP 9865)]
    [Thread 0xb53fdb70 (LWP 9864) exited]
    [Thread 0xb43fbb70 (LWP 9863) exited]
    [Thread 0xb4bfcb70 (LWP 9865) exited]
    [New Thread 0xb4bfcb70 (LWP 9867)]
    [New Thread 0xb43fbb70 (LWP 9868)]
    [New Thread 0xb53fdb70 (LWP 9869)]
    @

    Is there any reason Qt kills and spawns threads with every timer wait? This seems undesirable to me, is there a way to make QTimers not do this?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      AFAIK, QTimer does not use a thread, but you'd have to check the sources for your platform to be sure.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        medvedm
        wrote on last edited by
        #3

        I'm pretty sure that is what is doing. My debugger window will constantly spam those thread exited/thread created messages as long as I have my timers on. If I turn them off, no messages.

        1 Reply Last reply
        0

        • Login

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