一个不能编译通过的多线程示例程序
来源:互联网 发布:mac windows 共享软件 编辑:程序博客网 时间:2024/05/16 12:47
/* ------------------------------------------------------------------------------------------------- * test3.c * * Author : 多线程*** * Date : 2015-10-16 * Describe : 这是个十分简单的POSIX多线程程序。主线程创建两个子线程,并分别将1和2作为参数传递给子线 * 程,之后主线程将第一个子线程分离,将第二个子线程结合,之后主线程显示Hello world!。两个 * 子线程则执行相同的线程函数,先将参数pvoid转换成int型,然后再显示Hello world!,其中加入 * 了创建线程时传递的线程编号。 * 读者可以尝试将pthread_join语句去掉,或者换成pthread_exit(NULL),看看效果。 * Question : 该程序在Linux下,编译命令: # gcc -Wall test3.c -o test3 编译无法通过!原因待查! * ---------------------------------------------------------------------------------------------- */#include <stdio.h>#include <pthread.h>void * threadfunc(void *pvoid){int id = (int) pvoid;printf("Child thread%d says: Hello world!\n", id);return NULL;}int main(void){pthread_t tid1, tid2;pthread_create(&tid1, NULL, &threadfunc, 1);pthread_create(&tid2, NULL, &threadfunc, 2);pthread_detach(tid1);pthread_join(tid2, NULL);printf("Main thread says: Hello world!\n");return 0;}
一个有问题的示例。。。看来笔者可能没有经过上机验证
0 0
- 一个不能编译通过的多线程示例程序
- 一个多线程示例程序的BUG修复
- 编译通过但不能运行的程序最麻烦!
- 写一个只能C编译通过,而C++不能编译通过的函数。
- 一个简单的多线程示例
- 关于<<STL源码剖析>>中4.4.5节测试程序不能通过编译的说明
- 编译通过不能执行
- Windows程序运行不能通过的解决方案
- 多线程同步的一个小示例
- vc多线程的一个程序
- 编译directshow的示例程序baseclasses
- 编译directshow的示例程序baseclasses
- NotePad++编译运行C程序的示例
- delphi多线程程序示例
- delphi多线程程序示例
- 多线程程序示例
- gcc不能编译gdbm的程序
- 解决BCG库示例程序中的一个诡异编译错误
- 物联网通讯协议介绍
- Linux epoll详解
- 【cocos2d-js官方文档】九、cc.loader
- n皇后问题
- "library not found for - "解决办法
- 一个不能编译通过的多线程示例程序
- Android 启动模式中巧用singleTask
- Hibernate错误:Unable to build the default Bean Validator Factory
- Eventbus 详解,Activity和fragment通讯,相互发送接收数据
- elasicsearch suggest用法
- JQuery如何监听DIV内容变化
- java中静态代码块的用法 static用法详解
- for(object obj :args)
- 黑马程序员——【学习笔记】IO流——字符编码相关