C++ Boost 多线程(四),线程组

#include <iostream>
#include <boost/thread.hpp>

using namespace std;

void func1()
{
	cout<<"call func1()..."<<endl;
}

void func2()
{
	cout<<"call func2()..."<<endl;
}

int main()
{

	boost::thread_group group;
	for (int i=0; i<3; ++i)
	{
		group.create_thread(func1);
	}
	group.add_thread(new boost::thread(func2));
	cout<<"group.size() : "<<group.size()<<endl;
	group.join_all();

	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/u012592062/article/details/80469318