Search code examples
c++qtqthreadthread-priority

When should I use QThread::HighestPriority


  1. What are the benefits and harm of using HighestPriority in a QThread (QThread::HighestPriority)?

  2. This could harm some other operation?

  3. When should I use it?


Solution

    1. By using HighestPriority in your QT application you are giving that particular thread priority over all other threads within your application. This can be useful if you have multiple threads and want to make sure that your background threads do not steal CPU from your main thread. Harm? Not much harm can be done unless it's mis-used by human error.

    2. There's not much harm that can be done unless your application hogs cpu which usually results from a bug or poorly designed code.

    3. Use it when your application needs to do multiple things at once but you want to make sure, for example, that the main window stays responsive. Obviously to do so you just assign the main window HighestPriority.