Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_corelib_concurrent_qthreadpool.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QThreadPool>
5#include <QRunnable>
6#include <QDebug>
7
8//! [0]
10{
12 {
13 qDebug() << "Hello world from thread" << QThread::currentThread();
14 }
15};
16
17int main()
18{
19 //...
20 HelloWorldTask *hello = new HelloWorldTask();
21 // QThreadPool takes ownership and deletes 'hello' automatically
22 QThreadPool::globalInstance()->start(hello);
23 //...
24}
25//! [0]
void run() override
Implement this pure virtual function in your subclass.
int main()
[open]