[Qt-interest] End thread when work is done

Cole, Derek dcole at integrity-apps.com
Wed Aug 17 20:31:10 CEST 2011


Hello, I have the following:

        int maxThreads = QThreadPool::globalInstance()->maxThreadCount();
        int activeThreads =  QThreadPool::globalInstance()->activeThreadCount();

        for(int j = 0; j < maxThreads - activeThreads; j++ )
        {
            QFutureWatcher<bool> *procwatcher;
            procwatcher = new QFutureWatcher<bool>();
            procWatchers.push_back(procwatcher);


            QFuture<bool> procfuture = QtConcurrent::run(this, &EraserBatch::processTile);
            procFutures.push_back(procfuture);
            procwatcher->setFuture(procfuture);
            qDebug()<<"Active threadcount after proc "<<QThreadPool::globalInstance()->activeThreadCount();

        }

when "processTile" is finished running for each of these, the method returns fine, but when I check the activeThreadCount, it shows all of them still running. What can I put to make sure that each thread ends when the method to run has ended?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110817/0370334b/attachment.html 


More information about the Qt-interest-old mailing list