Unsolved Correct way to interrupt long running calculation inside a slot in another thread?
-
You can use your first example, an atomic bool and check this in every n'th iteration. Everything else is not needed and will not help.
You can also avoid the atomic bool and use the QThread built-in QThread::requestInterruption() and check for QThread::isInterruptionRequested() once in a while in your loop.