多线程
文章平均质量分 69
Jake2549794390
这个作者很懒,什么都没留下…
展开
-
线程的创建-1
#include #include using namespace std; void my_thread() { puts("hello, world"); } int main(int argc, char* argv[]) { thread t(my_thread);//实例化一个线程对象t,参数my_thread是一个函数,在线程创建完成后将被执行原创 2016-03-11 21:40:02 · 340 阅读 · 0 评论 -
线程的创建-2
#include #include #include using namespace std; void my_thread(int num, const string& str) { cout } int main(int argc, char* argv[]) { int num = 1234; string str = "tujiaw";原创 2016-03-11 22:25:40 · 283 阅读 · 0 评论 -
独占式互斥量
#include #include #include #include using namespace std; int g_num = 0;//多个线程同时访问共享资源的时候需要需要用到互斥量,当一个线程锁住了互斥量后,其他线程必须等待这个互斥量解锁后才能访问它。 mutex g_mutex;//独占式互斥量加解锁是成对的,同一个线程内独占式互斥量在没有解锁的情况下,再次对它原创 2016-03-11 23:13:07 · 342 阅读 · 0 评论