================================== #include <QtCore> // helloconcurrent/main.cpp void hello() { qDebug() << "Hello from thread " << QThread::currentThread(); } int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); ///重点分析下QFuture 和QtConcurrent这两个 关键字的用法!!!!!!!!!!!!!!!!!!!!!!!!!!!!! QFuture<void> future = QtConcurrent::run(hello);//thread-self自己函数就是一个线程. 暂时不懂QFuture和QtConcurrent的具体用法。 qDebug() << "hello from GUI thread " << QThread::currentThread(); future.waitForFinished(); return 0; } |