gpt4 book ai didi

c - 定义使用自身线程 ID 调用 join 的行为

转载 作者:太空宇宙 更新时间:2023-11-04 03:43:06 25 4
gpt4 key购买 nike

以下 C 语句的行为是什么:pthread_join(pthread_self(), NULL);

这是否意味着该线程将无法加入任何其他线程?

最佳答案

它产生未定义的行为:

如果 pthread_join() 的线程参数指定的值引用调用线程,则行为未定义

这里thread参数是第一个参数,调用thread是pthread_self():

                             v
int pthread_join(pthread_t thread, void **value_ptr);

http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html

关于c - 定义使用自身线程 ID 调用 join 的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26954326/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com