69,382
社区成员
发帖
与我相关
我的任务
分享
{
boost::threadpool::pool tp1(2), tp2(10); //定义两个线程池,tp1可以同时运行2个线程,tp2能同时运行10个(同时运行数目根据实际灵活调整)
tp1.schedule(&task1);
tp1.schedule(&task2);
tp1.wait(); //等待任务1、2完成
tp2.schedule(&task11); //执行任务11
tp1.schedule(&task3);
tp1.wait(); //等待任务3完成
tp2.schedule(&task12); //执行任务12
tp1.schedule(&task4);
tp1.wait(); //等待任务4完成
.......
tp2.schedule(&task18); //执行任务18
tp1.schedule(&task10);
tp1.wait(); //等待任务10完成
tp2.schedule(&task19); //执行任务19
tp2.schedule(&task20); //执行任务20
tp2.wait(); //等待任务11~20都完成。
}