上一页 1 ··· 30 31 32 33 34 35 36 37 38 ··· 68 下一页
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 condition_variable cv; 11 mutex m; 12 bool done = false; 13 14 void run() 15... 阅读全文
posted @ 2018-03-12 16:08 喵小喵~ 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 #define N 100000 7 8 mutex g_mutex; 9 10 void add(int *p) 11 { 12 for (int i = 0; i lgd(g_mutex); 16 //unique也能... 阅读全文
posted @ 2018-03-12 15:56 喵小喵~ 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 5 //交换线程,线程移动 6 void main() 7 { 8 thread t1([]() {cout << "hello" << endl; }); 9 thread t2([]() {cout << "hello3" << endl; }); 10 ... 阅读全文
posted @ 2018-03-12 15:49 喵小喵~ 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 1 //编写一个 程序,开启3个线程,这3个线程的ID分别为A,B,C 2 //每个线程将自己的ID在屏幕打印10遍 3 //要求输出结果必须按ABC的顺序显示 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 int LOOP = 10; 11 int flag = 0; ... 阅读全文
posted @ 2018-03-12 15:44 喵小喵~ 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define COUNT 1000000 10 11 //创建互斥量 12 mutex m; 13 14 //多... 阅读全文
posted @ 2018-03-12 15:23 喵小喵~ 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int go(const char *fmt, ...) 9 { 10 va_list ap;//指针 11 va_start(ap, fmt)... 阅读全文
posted @ 2018-03-12 15:00 喵小喵~ 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 创建vector数组 1 vector<int> myint{ 1,2,3,4,5 }; 尾部插入 1 for (int i = 10; i < 20; i++) 2 { 3 myint.push_back(i); 4 5 } 读取头部和尾部 1 cout << myint.front() << e 阅读全文
posted @ 2018-03-12 14:51 喵小喵~ 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include //线程将来的结果 5 #include 6 #include 7 using namespace std; 8 9 mutex g_m; 10 11 12 void main() 13 { 14 auto run = [... 阅读全文
posted @ 2018-03-12 14:44 喵小喵~ 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 //线程通信,结合mutex 9 //一个线程,多个线程处于等待,通知一个或者通知多个 10 11 mutex m;//线程相互排斥 12 conditio... 阅读全文
posted @ 2018-03-12 11:26 喵小喵~ 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 promise val;//全局通信变量 10 void main() 11 { 12 //字符串相加 13 /*st... 阅读全文
posted @ 2018-03-12 10:59 喵小喵~ 阅读(277) 评论(0) 推荐(0) 编辑
上一页 1 ··· 30 31 32 33 34 35 36 37 38 ··· 68 下一页