知识链接:
C++11 并发之std::atomic
本文概要:
1、成员类型和成员函数。
2、std::thread 构造函数。
3、异步。
4、多线程传递参数。
5、join、detach。
6、获取CPU核心个数。
7、CPP原子变量与线程安全。
8、lambda与多线程。
9、时间等待相关问题。
10、线程功能拓展。
11、多线程可变参数。
12、线程交换。
13、线程移动。
std::thread 在 #include<thread> 头文件中声明,因此使用 std::thread 时需要包含 #include<thread> 头文件。
1、成员类型和成员函数。
成员类型:
-
id
- Thread id (public member type ) id
-
native_handle_type
- Native handle type (public member type )
成员函数:
-
(constructor)
- Construct thread (public member function ) 构造函数
-
(destructor)
- Thread destructor (public member function ) 析构函数
-
operator=
- Move-assign thread (publ