下面的代码中,是否需要pthread_yield()在主线程阻塞等待时调用pthread_join()?
void *myThread(void *result)
{
//do something here
return 0;
}
int main()
{
pthread_t tid;
void *status = 0;
int result;
pthread_create(&tid, NULL, myThread, &result);
// do I need pthread_yield() here?
pthread_join(tid, &status);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果不是,什么是有效的用例pthread_yield()?我能想到的大多数基本情况,操作系统/调度程序已经自动处理了。