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 页面调接口时加载卡住不响应
- ¥35 用C语言解决编程问题
- ¥15 unity硬件连接与使用
- ¥15 鱼缸加热棒的数据分析或者实际案例也行
- ¥15 postgresql11安装完成后,pgadmin无法启动
- ¥15 (标签-无人机|关键词-Matlab代码)
- ¥15 执行shell脚本提示参数太多
- ¥15 困扰好久了,电脑的串口调试助手向单片机发送一个字符(如:字符‘1’到‘8’),单片机点亮对应的灯(如发送字符‘2’则点亮第2个灯)并给电脑回复信息:已点亮第x个灯(其中 x 要替换成对应的数字)
- ¥15 求减少这个c++程序内存的解决方案
- ¥30 改正代码,错误比较多