
多线程
多线程
哈士奇超帅
我变秃了 也变强了
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
并发库的简单比较
本章比较了 C++11 STL、boost、POSIXC、java 并发库间的区别原创 2018-10-25 14:26:31 · 293 阅读 · 0 评论 -
C++ STL <mutex> 互斥体
ee原创 2018-09-28 10:02:40 · 1061 阅读 · 0 评论 -
C++ STL <thread> 创建线程的三种方式
使用 stl thread 编写多线程程序时,编译需要加 -pthread通过函数指针创建线程#include <iostream>#include <thread>using namespace std;void func(int id, int number){ for(int i=0;i<number;++i) {...原创 2018-10-24 10:50:37 · 4751 阅读 · 0 评论 -
C++ STL <atomic> 原子类型
使用 std::this_thread::sleep_for 编译时需要加上:-std=c++0x -pthread -D_GLIBCXX_USE_NANOSLEEP未使用原子变量可能引起竞争,导致最后的counter可能不等于10000:#include &amp;lt;iostream&amp;gt;#include &amp;lt;vector&amp;gt;#include &amp;lt;thread&原创 2018-10-24 10:58:42 · 699 阅读 · 0 评论