#include <boost/bind.hpp>
#include <iostream>
using namespace boost;
using namespace std;
void runChild(const
int n)
{
cout << "我是第"
<< n << "个子线程"
<< endl;
sleep(1);
cout << "进程"
<< n << "退出"
<< endl;
}
int main( )
{
int num;
thread_group threads;
cout << "请提供一个要生成线程数的参数" << endl;
cin>> num;
cout << "我是主程序,我准备产生"
<< num << "个子线程"
<< endl;
for(int i
= 0; i
< num; i++)
{
threads.create_thread(bind(&runChild, this,ref(i)));
}
cout << "我是主程序,我在等子线程运行结束"
<< endl;
threads.join_all();
return 0;
}