- 论坛徽章:
- 0
|
程序如下:
#include <pthread.h>
#include <stdio.h>
void *mm()
{
printf("======debug\n");
}
int main()
{
pthread_t a_thread;
int res = pthread_create(&a_thread, NULL, mm, NULL);
printf("res = %d\n", res);
int i = 100000000;
while(i--){};
printf("======main()\n");
}
运行结果为:(ubuntu 7.04上编译运行)
res = 0
======main()
分析:
返回值res为0,说明创建新线程成功,但是却没有输出“======debug”
另外,该程序在其他机器上跑可以得到正确结果:(如下)
res = 0
======debug
======main()
猜测:
似乎是pthread库有问题,之前跑多线程程序是对的,没过几天突然就不行了,中间我好像更新了什么东西,不仅这个多线程程序运行有问题,连用g++编译简单的c++程序都会出头文件的问题
请高手解惑,谢谢!
[ 本帖最后由 yoyocall 于 2008-11-10 18:14 编辑 ] |
|