64,639
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <algorithm>
//线程类和线程池类,放在C盘了
#include <C:/Thread.h>
#include <C:/ThreadPool.h>
// 或者合在一起:#include<C:/Threads.h>
using namespace std;
int inplus()
{
int a, b;
cout << "输入a, b:";
cin >> a >> b;
int c = a + b;
cout << "答案:" << c << endl;
return c;
}
void sortlist(int len)
{
int *list = new int[len];
for (int i = 0; i < len; i++) cin >> list[i];
sort(list, list + len + 1);
cout << "排序结果:";
for (int i = 0; i < len; i++) cout << list[i] << ' ';
cout << endl;
}
int main()
{
Thread t1(inplus), t2(sortlist, 5); //定义(未就绪)
t1.start(); //启动(开始就绪,等待运行)
t2.start();
t1.wait(); //等待运行结束
t2.wait();
//...其他效果后面说
return 0;
}