09 2019 档案

摘要:1.等待事件 std::mutex m; void wait() { std::unique_lock<std::mutex> lk(m); lk.unlock(); std::this_thread::sleep_for(std::chrono::millisenconds(100));//休眠1 阅读全文
posted @ 2019-09-23 20:14 penuel 阅读(403) 评论(0) 推荐(0)
摘要:1.初始化 2.string的一些操作 + empty:返回一个布尔值来判断是否非空 + size:返回对象的长度,无符号整形 + 关系运算:== = 80 ) cout 阅读全文
posted @ 2019-09-23 19:49 penuel 阅读(602) 评论(0) 推荐(0)
摘要:1.std::mutex类 1.构造函数,std::mutex不允许拷贝构造,也不允许 move 拷贝,最初产生的 mutex 对象是处于 unlocked 状态的。 2.lock(),调用线程将锁住该互斥量。线程调用该函数会发生下面 3 种情况:①如果该互斥量当前没有被锁住,则调用线程将该互斥量锁 阅读全文
posted @ 2019-09-23 11:33 penuel 阅读(560) 评论(0) 推荐(0)
摘要:1.先上几个视频网站 1. "英文" 2. "中文" 阅读全文
posted @ 2019-09-23 11:26 penuel 阅读(158) 评论(0) 推荐(0)
摘要:void function(); void function1(); std::thread t1( function ); //启动一个新线程t1与function关联 std::thread t2 = std::move(t1); //将t1限行的转移给t2 t1 = std::thread( 阅读全文
posted @ 2019-09-04 19:49 penuel 阅读(259) 评论(0) 推荐(0)
摘要:#include <iostream>#include <thread>#include <windows.h> using namespace std;void switch_ab (int &a, int &b) //参数是引用可更改 //void switch_ab (int &a, int 阅读全文
posted @ 2019-09-04 19:22 penuel 阅读(351) 评论(0) 推荐(0)
摘要:#include <iostream>#include <thread>#include <unistd.h>void hello(){ while(1) { std::cout << "hello world" << std::endl; for(int i=0;i<999999999;i++); 阅读全文
posted @ 2019-09-04 19:11 penuel 阅读(202) 评论(0) 推荐(0)