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 }
博客园 © 2004-2025 浙公网安备 33010602011771号 浙ICP备2021040463号-3