- 论坛徽章:
- 0
|
回复 3# uhnafhll
你这问题一看就知道**非共性问题** , 当然你得提供个简单的代码,然后我们再直接copy后试验。才能给出答案吧。
我顺手写了个.
当子线程退出,那么整个程序就会结束。
目前已经运行了1分钟,没发现异常。 我去吃个饭,看他退出没有 (我估计是不会退出) 。
初步猜测是你的程序可能太大型了,自己写的代码问题。
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void *thread(void *args)
{
int i;
i = 1;
while(i)
{
;
}
return NULL;
}
int main(void)
{
pthread_t tid;
void *stat;
if(pthread_create(&tid , NULL ,
thread , NULL) != 0) {
fprintf(stderr , "pthread_create error\n");
exit(-1);
}
if(pthread_join(tid , &stat) != 0){
fprintf(stderr , "pthread_join error\n");
exit(-1);
}
printf("warning! thread exit!\n");
exit(0);
} |
|