1 #include
2 #include
3 #include
4 #include
5
6
7 void *thr_fn1(void *arg)
8 {
9 printf("thread 1 returning\n");
10 return((void *)1);
11 }
12
13 void *thr_fn2(void *arg)
14 {
15 printf("thread 2 exiting\n");
16 return((void *)2);
17 }
18
19 int main(void)
20 {
21 pthread_t tid1,tid2;
22 void *tret;
23 pthread_creat(&tid1,NULL,thr_fn1,NULL);
24 pthread_creat(&tid2,NULL,thr_fn2,NULL);
25 pthread_join(tid1,&tret);
26 printf("thread 1 exit code %d\n",(int)tret);
27 pthread_join(tid2,&tret);
28 printf("thread 2 exit code %d\n",(int)tret);
29 exit(0);
30 }
linux下 c/c++多线程简单程序编译不过
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答
悬赏问题
- ¥15 关于#python#的问题:求帮写python代码
- ¥20 MATLAB画图图形出现上下震荡的线条
- ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
- ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
- ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
- ¥15 perl MISA分析p3_in脚本出错
- ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
- ¥15 ubuntu虚拟机打包apk错误
- ¥199 rust编程架构设计的方案 有偿
- ¥15 回答4f系统的像差计算