0
我对并行线程蒙山这个小C源问题:pthread_join成功=线程完全执行?
int calc = 0;
void func(void* data){
calc = 2 * 2;
return NULL;
}
int main(){
pthread_t t;
if(0==pthread_create(&t,NULL,func,NULL)){
if(0==pthread_join(t,NULL)){
printf("Result: %d\n",calc); // 4 ?
}
}
}
如果在pthread_join返回成功,是“功能”总是完全执行? (在printf上calc总是等于4)?
是什么的文件'pthread_join'说? – 2014-01-30 13:21:11
函数原型中有一个输入错误,应该是void * func(void * data)。 – MichaelGoren