gpt4 book ai didi

c - thrd_join 的返回值与其 res 参数的区别?

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

我很难理解 thrd_join 的用法。它的声明是这样的:

int thrd_join( thrd_t thr, int *res );

该部分内容如下:

If res is not a null pointer, the result code of the thread is put to the location pointed to by res

所以我认为变量res 包含要加入的线程的返回码。 thrd_join() 的返回值是干什么用的?那是一个代码,表示加入成功,我可以认真对待res的内容吗?

我说得对吗?

最佳答案

线程是started具有 thrd_start_t 的函数,它是 int(*)(void*) 的类型定义(参见 here ),即它需要一个 void *,并返回一个int。此函数的返回值存储到 res 指向的位置。调用 thrd_join 的返回码本身就是它的返回值。

关于c - thrd_join 的返回值与其 res 参数的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44291402/

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