How many implicit thread? (Windows mingw)



  • Someone know then Qt creates implicit threads? That is, for instance, I notice that using QTimer::singleShot() with a delay greater then zero create a new thread.

    I have an application that create a QThread by its own and an implicit thread with the Windows multimedia timer, but the total count of the application thread is 4 (after the start of the multimedia timer). I'm quite sure I have only zero-delayed singleShot() timer (in two the form class constructor), then some startTimer()/timerEvent() both in some "designer-created" class and in some class defined and instantiated in .cpp file.

    I expected to have one main thread, one multimedia timer thread and one worker thread, for a total of 3 against the actually 4.

    Maybe the multimedia timer create more than one thread, but I thinks this is not the case since the number of threads is incremented by one (from 3 to 4) only then I start the timer.

    Maybe there is a bug in my code, but so far I'm quite sure I create only one additional worker thread.

    With the debugger I can easily identify the main thread, the worker and, once started, the multimedia one. The other 1 seems to be waiting in a Sleep or somewhere in the windows kernel (RrcBCacheFree). When debugging I have two more thread.

    The GUI (win32-mingw) is composed by a QMainWindow with some docks and a QTabWidget for the central area. The tab uses some QTreeWidget (that, it seems to me, implicitly use timerEvent() to manages some updates). It doesn't use the network of other particular resources.


  • Moderators

    I do not understand your problem. Is this just curiosity about where the threads you observe come from or are the threads triggering some problem for you?



  • Sounds like the QtConcurrent thread pool...



  • [quote author="Tobias Hunger" date="1291149234"]I do not understand your problem. Is this just curiosity about where the threads you observe come from or are the threads triggering some problem for you? [/quote]

    Mainly curiosity. Apparently these threads don't trigger any problem (I could have a bug somewhere and instantiate a class twice, but I already check for that and it seems this is not the case).

    My application is soft real-time (as far it is possible with Windows XP), the worker thread is at time critical priority and it seems it is not affected by the phantom thread. Anyway, I would like to know the usage of the resources.



  • calberto, Qt itself creates threads sometimes (for example when you are using QtScript), but as you say your app should not be affected much by such threads. Most of time they are in sleep.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.