- 实际上Qt的ThreadPool和java的线程池使用起来比较像,简单的例子如下:
class HelloWorldTask : public QRunnable
{
void run()
{
qDebug() << "Hello world from thread" << QThread::currentThread();
}
}
HelloWorldTask *hello = new HelloWorldTask();
QThreadPool::globalInstance()->start(hello);
int activeThreadCount() const
int maxThreadCount() const
void setMaxThreadCount(int maxThreadCount)
void QThreadPool::start(QRunnable * runnable, int priority = 0)
void QThreadPool::waitForDone()
bool QThreadPool::waitForDone(int msecs)
- 这些看名字就大致知道是怎么回事了,就不再意义介绍了