#include <thread>
void ThreadDlg::thread_fun(int nValue)
{
for (int i = 0; i < nValue; i++)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}
void ThreadDlg::thread_fucAdd(int nValue, int nValue1)
{
int nResult = 2 * nValue + nValue1;
}
void ThreadDlg::on_btnTestThread_clicked()
{
std::thread myThread(&ThreadDlg::thread_fun, this, 10);
myThread.detach();
std::thread myThread1(&QtTestCppThread::thread_fucAdd, this, 10, 20);
myThread1.detach();
}
纯C++方式创建线程
于 2023-08-15 16:39:10 首次发布