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
阅读全文
摘要:1.初始化 2.string的一些操作 + empty:返回一个布尔值来判断是否非空 + size:返回对象的长度,无符号整形 + 关系运算:== = 80 ) cout
阅读全文
摘要:1.std::mutex类 1.构造函数,std::mutex不允许拷贝构造,也不允许 move 拷贝,最初产生的 mutex 对象是处于 unlocked 状态的。 2.lock(),调用线程将锁住该互斥量。线程调用该函数会发生下面 3 种情况:①如果该互斥量当前没有被锁住,则调用线程将该互斥量锁
阅读全文
摘要:void function(); void function1(); std::thread t1( function ); //启动一个新线程t1与function关联 std::thread t2 = std::move(t1); //将t1限行的转移给t2 t1 = std::thread(
阅读全文
摘要:#include <iostream>#include <thread>#include <windows.h> using namespace std;void switch_ab (int &a, int &b) //参数是引用可更改 //void switch_ab (int &a, int
阅读全文
摘要:#include <iostream>#include <thread>#include <unistd.h>void hello(){ while(1) { std::cout << "hello world" << std::endl; for(int i=0;i<999999999;i++);
阅读全文

浙公网安备 33010602011771号