code_fodder
code_fodder

Reputation: 16321

Qt seems to use lots of threads

I have used Qt quite a lot, but recently needed to debug the threads I have been creating and found many more threads then I was expecting.

So my program is a simple console only (no GUI) Qt application (linux).

Threads that I have created:

And that is all. When I do ps -T... and find my application there are 7 threads. I have two classes that are QObjects using signals and slots, so maybe they need a thread each for message handling, that takes me to 4 threads... so I am at a loss as to why I might have 7 threads for my application.

Can anyone explain more about what is going on? can post code if needed. Note I only use new QThread once in my code (for the moment).

Upvotes: 2

Views: 968

Answers (1)

Qt doesn't create any per-QObject threads. It creates helper threads for some plaform-specific reasons, e.g. QProcess sometimes needs helper threads.

The FTDI D2XX unix driver uses libusb and that implementation is completely backwards and uses additional threads on top of the thread you've provided for it. Frankly said, you shouldn't be using the D2XX driver on Linux or OS X. Just use the kernel driver.

You should simply run the D2XX driver in a trivial non-Qt test application that opens the device and reads from it continuously and see how many threads it spawns. You'll be dismayed...

Upvotes: 6

Related Questions