赞
踩
- /**
- * @author jsq
- * @date 20210613
- * @function: 学习std::future模板类、std::async()、std::packaged_task()模板类、std::promise()模板类的使用
- * @notice:
- */
- #include <iostream>
- #include <thread>
- #include <vector>
- #include <list>
- #include <mutex>
- #include <future>
- using namespace std;
-
- class A {
-
- public:
-
- int APrint(int para) {
-
- cout << "用对象成员函数创建的线程开始执行!" << endl;
- std::chrono::milliseconds dura(2000);
- std::this_thread::sleep_for(dura);
- cout << "children thread id:" << std::this_thread::get_id() << endl;
- cout << "para is:" << para << endl;
- cout << "用对象成员函数创建的线程执行完毕!" << endl;
-
- return 666;
- }
- };
-
-
- int myprint() {
-
- cout << "子线程开始执行!" << endl;
-
- std::chrono::milliseconds dura(5000);
- std::this_thread::sleep_for(dura);
- cout << "current thread id:" << std::this_thread::get_id() &l
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。