Because usage of the low-level threading constructs is known to be error-prone (we have seen a list of the problems earlier in this chapter), there is an ongoing quest in the concurrent community to provide better and higher level abstractions. Qt also implements a couple of such mechanisms and groups them in the QtConcurrent module. Let's have a look at it.
Higher level Qt concurrency mechanisms
QThreadPool
A thread pool preallocates a number of worker threads and then allows the user to use them for their run computations. Each Qt application has one global QThreadPool object, which can be accessed by calling globalInstance(). QThreadPool allows running instances of QRunnable (also known as tasks) by calling QThreadPool...