导航

C++11 thread

Posted on 2016-06-21 00:38  codetask  阅读(129)  评论(0)    收藏  举报
 1 //这里使用c++的thread创建了5个线程,并支持传递多个参数
 2 void thread1(int aa,int bb)
 3 {
 4     cout << aa << bb << endl;
 5 }
 6 
 7 void testthread()
 8 {
 9     int ithreads[] = {1,2,3,4,5};
10     for(auto i: ithreads)
11     {
12         thread t1(thread1,i,i+1);
13         t1.join();
14     }
15 }