Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QTimers spawn new threads every time?

    General and Desktop
    2
    3
    1723
    Loading More Posts
    • 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
      medvedm last edited by

      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 Reply Quote 0
      • A
        andre last edited by

        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 Reply Quote 0
        • M
          medvedm last edited by

          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 Reply Quote 0
          • First post
            Last post