标签:bool rup details 调用 on() isinf ini nbsp vat
Qt5已经分装了函数
void QThread::requestInterruption() { Q_D(QThread); QMutexLocker locker(&d->mutex); if (!d->running || d->finished || d->isInFinish) return; if (this == QCoreApplicationPrivate::theMainThread) { qWarning("QThread::requestInterruption has no effect on the main thread"); return; } d->interruptionRequested = true; } bool QThread::isInterruptionRequested() const { Q_D(const QThread); QMutexLocker locker(&d->mutex); if (!d->running || d->finished || d->isInFinish) // 如果线程已经结束就。。。 return false; return d->interruptionRequested; }
在wile中用下面函数判断
while (!isInterruptionRequested()) { ///// ///// }
在析构函数中调用
ThreadToDisks:: ~ThreadToDisks()
{
requestInterruption();
quit();
wait();
}
参考:https://blog.csdn.net/u013372900/article/details/80405261
QThread: Destroyed while thread is still running
标签:bool rup details 调用 on() isinf ini nbsp vat
原文地址:https://www.cnblogs.com/herd/p/11656299.html