Multithreading in QT using QtConcurrent

爱⌒轻易说出口 提交于 2019-12-05 11:43:54

The future of QtConcurrent seems to be uncertain if you read this thread.

Having more threads that processing cores is somewhat redundant. If you have one core and 2 threads running, the processor spends time switching between the processing the 2 threads, but gives the user the appearance of simultaneous processing.

With the same number of cores and threads, the threads can be split between the cores.

Once you have more cores than threads, you're back to the original method of cores jumping up and back between the threads that it is required to process.

Using QThread is actually very easy to do as QThread is not directly a thread, but a thread controller. You can read about how to 'really truly use QThreads' here.

As it describes, you create objects inherited to QObject and move that to a QThread. What is rarely mentioned is that you can move multiple objects to the new QThread, if required.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!