作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个小代码
void *PrintHello(void *threadid)
{
cout<<"Hello"<<endl;
pthread_exit(NULL);
}
int main ()
{
pthread_t threads_id;
pthread_create(&threads_id, NULL, PrintHello, NULL);
int i=0;
for(;i<100;i++){cout<<"Hi"<<endl;}
pthread_join(threads_id,NULL);
return 0;
}
我会在创建后的某个时间加入线程。如果 main 试图加入一个已经退出的线程,会发生什么?
最佳答案
What will happen if the main tries to join a thread which already exited?
连接操作将立即完成并返回。
关于c++ - 如果线程在调用 pthread_join 之前退出怎么办,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29314738/
我是一名优秀的程序员,十分优秀!