床塌了有什么预兆| 演唱会安可是什么意思| 脱发厉害是什么原因引起的| lala是什么意思| 老豆腐和嫩豆腐有什么区别| 鸡蛋和什么食物相克| 怀孕会有什么症状| 英特纳雄耐尔是什么意思| 季昌明是什么级别| 梦到自己杀人是什么意思| 京东e卡是什么| 饺子有什么馅| 大便很臭什么原因| 什么是基本养老金| 朱砂有什么用| 痤疮是什么原因引起的| 三月三日是什么星座| 睡醒后口干口苦是什么原因| 颌下腺肿大是什么原因| 衍生物是什么意思| wtf是什么意思| 5月31日什么星座| 豆腐干炒什么好吃| 什么是跨境电商| 什么是透析治疗| 幽门螺旋杆菌做什么检查| 厚植是什么意思| 盐碱地适合种什么农作物| 吃什么食物排湿气| 忠字五行属什么| 冰岛茶属于什么茶| 金庸的原名叫什么| cm什么意思| 吃石斛有什么好处| 大黄是什么| 七月份生日是什么星座| 孕妇梦见洪水是什么意思| 处级干部是什么级别| 小儿流清鼻涕吃什么药效果好| 4月23日是什么星座| 小米什么时候成熟| 3岁宝宝流鼻血是什么原因| infp是什么意思| 老八是什么意思| 水绿色是什么颜色| 脚背肿是什么原因引起的| 十斋日是什么意思| 洒水车的音乐是什么歌| 喝酒后头疼是什么原因| 市盈率和市净率是什么意思| 胆固醇高有什么危害| 海参什么时间吃最好| 排骨汤什么时候放盐最好| 血氧饱和度是什么意思| 孩子爱流鼻血是什么原因| 秀女是什么意思| 152是什么意思| 高定是什么意思| 山药对人体有什么好处| 主动脉迂曲是什么意思| 小孩什么时候换牙| 口腔长期溃疡是什么原因引起的| 糖类抗原50是什么指标| 肚子为什么会胀气| 胰岛素抵抗是什么意思| 日光灯属于什么光源| 宝宝佛适合什么人戴| 什么是皮疹| 什么钙片补钙效果最好| 什么茶最好| 荔枝不能和什么一起吃| 女生肚子大是什么原因| 打胎药叫什么| 飞蚊症用什么眼药水| 现在什么餐饮最火| 夏天可以种什么花| 附睾炎吃什么药最有效| 什么的大自然| 石青色是什么颜色| 键盘侠是什么意思| 网络绿茶是什么意思| 抗核抗体谱检测查什么的| 青筋明显是什么原因| 胰是什么器官| 胀气吃什么食物好| 标间是什么意思| 大便黄绿色是什么原因| 苯三酚注射有什么用| 微信中抱拳是什么意思| 着床成功后有什么症状或感觉| 清鱼是什么鱼| 孕妇做春梦是什么意思| 人为什么要抽烟| 正常的精液是什么样的| 喝酒对身体有什么影响| 蔬菜用什么肥料最好| 高血压吃什么好| 血脂是什么意思| pao2是什么意思| 今天吃什么| 冬虫夏草什么价格| 缺维生素会有什么症状| 碳酸盐质玉是什么玉| c2m模式是什么意思| 月经不调是什么症状| ons是什么意思| tbs和tct有什么区别| 五十年是什么婚| nasa是什么牌子| 病毒性咳嗽吃什么药好| 六月份是什么季节| 什么都不做| 孕妇梦见老公出轨是什么意思| 刻舟求剑什么意思| mm什么意思| 晚上老是做梦是什么原因| 东海龙王叫什么名字| 肚子上方中间疼是什么部位| 甲功三项是检查什么| ip地址是什么意思| 蜘蛛痣是什么原因引起的| 高考什么时候恢复| 黄豆什么时候种| 秋葵吃多了有什么坏处| 孕妇刚生完孩子吃什么好| 结甲可能是什么意思| 筋膜炎吃什么药好得快| 小拇指发麻是什么原因| 蜂蜜对人体有什么好处和功效| 流鼻血挂什么科| 为什么会有跳蚤| 戒指戴左手食指是什么意思| 右眼皮跳什么原因| 眼泡是什么意思| 什么是点天灯| 核医学科主要治什么病| 家什是什么意思| 摩丝是什么| 予字五行属什么| as是什么| 张嘴睡觉有什么危害| 白羊座和什么星座最配| 饮料喝多了有什么危害| 十二指肠球炎是什么意思| 喝茶水对身体有什么好处| 一 什么云| 新生儿湿肺是什么意思| 成何体统是什么意思| 冚家铲是什么意思| 益生菌有什么作用| 心跳过缓吃什么药| 227是什么意思| 小便尿出乳白色液体是什么问题| 西瓜和什么食物相克| 八面玲珑是什么意思| 轩字属于五行属什么| 切除痣挂什么科| 生理期吃什么好| 甲状腺球蛋白抗体高是什么意思| 有缘无分是什么意思| 79年出生属什么生肖| 大陆去台湾需要什么手续| 查甲功是什么意思| 仿水晶是什么材质| 最坚固的锁怕什么| 腿麻是什么原因引起的| 唐筛21三体临界风险是什么意思| 我什么都可以| 蛮夷是什么意思| 右肋骨下方隐隐疼痛是什么原因| 什么伤肝| 鹅口疮用什么药效果好| 男人毛发旺盛说明什么| 梦见知了猴是什么意思| 胃潴留是什么病| 毛周角化症是什么原因引起的| 什么是肾虚| 今天晚上吃什么| 蛀牙是什么原因引起的| 戒烟为什么会长胖| 手指甲有黑色条纹是什么原因| 涤纶是什么材料| 便宜的反义词是什么| 看病人带什么水果| 可卡因是什么| 耳目比喻什么| 观音菩萨姓什么| 什么是摇滚| 心脏早搏吃什么药最好| 寸金难买寸光阴什么意思| 鞋子上eur是什么意思| 截瘫是什么意思| 火腿炒什么菜好吃| 宫颈切片检查是什么| 90年属什么的生肖| 子宫是什么样子图片| 炸东西用什么油| 蚊子不喜欢什么味道| 应酬是什么意思| 什么食物含叶酸多| 今年什么时候起伏| 2028什么年| 化骨龙是什么意思| 透析病人磷高了吃什么降磷| 一模一样的意思是什么| 白色念珠菌是什么病| 77年属蛇的是什么命| 相依相偎是什么意思| 为什么猫怕水| 吃阿胶对女人有什么好处| 化学性肝损伤是什么意思| 毛豆有什么营养价值| 一箭双雕是什么生肖| 没壳的蜗牛叫什么| 洋酒兑什么饮料好喝| 祛湿喝什么| 5.13是什么星座| 帆布是什么材质| 小便带血什么原因| 因地制宜是什么意思| 无锡机场叫什么名字| 经常打哈欠是什么原因| 恶性贫血是什么意思| t是什么| 六月十三是什么日子| 桂枝和肉桂有什么区别| 好高什么远| 外甥女是什么关系| 不排大便是什么原因| 结核感染是什么意思| 突然耳鸣是什么原因| 心脏杂音是什么意思| 脖子粗大是什么病的症状| 热疹症状该用什么药膏| edp是什么意思| 广西属于什么气候| 睡觉身上痒是什么原因| 拉肚子是什么原因| 厮守是什么意思| 一什么眉毛| 刘邦为什么要杀韩信| 霉菌性阴道炎用什么药| 财不外露什么意思| cr是什么金属| 膝盖疼痛吃什么药好| 江西有什么特产| 小孩流鼻血吃什么好| 经常喝红茶有什么好处和坏处吗| 吃什么补肾壮阳最快速| jewelry什么意思| 两肋胀满闷胀是什么病| 火龙果什么时候开花| 亢奋什么意思| 什么是工科| 客厅用什么灯具好| 眼角膜脱落什么症状| 牙膏尾部的颜色代表什么意思| 秋五行属什么| 女同学过生日送什么礼物比较好| 眼睛大小不一样是什么原因| 烟火气是什么意思| dr拍片是检查什么的| 慢性咽喉炎吃什么药好| 三维是什么意思| 百度
The Open Group Base Specifications Issue 8
IEEE Std 1003.1-2024
Copyright ? 2001-2024 The IEEE and The Open Group

NAME

pthread_join — wait for thread termination

SYNOPSIS

#include <pthread.h>

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

DESCRIPTION

The pthread_join() function shall suspend execution of the calling thread until the target thread terminates, unless the target thread has already terminated. On return from a successful pthread_join() call with a non-NULL value_ptr argument, the value passed to pthread_exit() by the terminating thread shall be made available in the location referenced by value_ptr. When a pthread_join() returns successfully, the target thread has been terminated. The results of multiple simultaneous calls to pthread_join() specifying the same target thread are undefined. If the thread calling pthread_join() is canceled, then the target thread shall not be detached.

It is unspecified whether a zombie thread counts against {PTHREAD_THREADS_MAX}.

The behavior is undefined if the value specified by the thread argument to pthread_join() does not refer to a joinable thread.

The behavior is undefined if the value specified by the thread argument to pthread_join() refers to the calling thread.

If thread refers to a thread that was created using thrd_create() and the thread terminates, or has already terminated, by returning from its start routine, the behavior of pthread_join() is undefined. If thread refers to a thread that terminates, or has already terminated, by calling thrd_exit(), the behavior of pthread_join() is undefined.

RETURN VALUE

If successful, the pthread_join() function shall return zero; otherwise, an error number shall be returned to indicate the error.

ERRORS

The pthread_join() function may fail if:

[EDEADLK]
A deadlock was detected.

The pthread_join() function shall not return an error code of [EINTR].


The following sections are informative.

EXAMPLES

An example of thread creation and deletion follows:

typedef struct {
    int *ar;
    long n;
} subarray;

void * incer(void *arg) { long i;
for (i = 0; i < ((subarray *)arg)->n; i++) ((subarray *)arg)->ar[i]++; }
int main(void) { int ar[1000000]; pthread_t th1, th2; subarray sb1, sb2;
sb1.ar = &ar[0]; sb1.n = 500000; (void) pthread_create(&th1, NULL, incer, &sb1);
sb2.ar = &ar[500000]; sb2.n = 500000; (void) pthread_create(&th2, NULL, incer, &sb2);
(void) pthread_join(th1, NULL); (void) pthread_join(th2, NULL); return 0; }

APPLICATION USAGE

None.

RATIONALE

The pthread_join() function is a convenience that has proven useful in multi-threaded applications. It is true that a programmer could simulate this function if it were not provided by passing extra state as part of the argument to the start_routine(). The terminating thread would set a flag to indicate termination and broadcast a condition that is part of that state; a joining thread would wait on that condition variable. While such a technique would allow a thread to wait on more complex conditions (for example, waiting for multiple threads to terminate), waiting on individual thread termination is considered widely useful. Also, including the pthread_join() function in no way precludes a programmer from coding such complex waits. Thus, while not a primitive, including pthread_join() in this volume of POSIX.1-2024 was considered valuable.

The pthread_join() function provides a simple mechanism allowing an application to wait for a thread to terminate. After the thread terminates, the application may then choose to clean up resources that were used by the thread. For instance, after pthread_join() returns, any application-provided stack storage could be reclaimed.

The pthread_join() or pthread_detach() function should eventually be called for every thread that is created with the detachstate attribute set to PTHREAD_CREATE_JOINABLE so that storage associated with the thread may be reclaimed.

The interaction between pthread_join() and cancellation is well-defined for the following reasons:

Thus, only the default cancelability state need be considered. As specified, either the pthread_join() call is canceled, or it succeeds, but not both. The difference is obvious to the application, since either a cancellation handler is run or pthread_join() returns. There are no race conditions since pthread_join() was called in the deferred cancelability state.

If an implementation detects that the value specified by the thread argument to pthread_join() does not refer to a joinable thread, it is recommended that the function should fail and report an [EINVAL] error.

If an implementation detects that the value specified by the thread argument to pthread_join() refers to the calling thread, it is recommended that the function should fail and report an [EDEADLK] error.

If an implementation detects use of a thread ID after the end of its lifetime, it is recommended that the function should fail and report an [ESRCH] error.

The pthread_join() function cannot be used to obtain the exit status of a thread that was created using thrd_create() and which terminates by returning from its start routine, or of a thread that terminates by calling thrd_exit(), because such threads have an int exit status, instead of the void * that pthread_join() returns via its value_ptr argument.

FUTURE DIRECTIONS

None.

SEE ALSO

pthread_create(), thrd_create(), thrd_exit(), wait()

XBD 4.15.2 Memory Synchronization, <pthread.h>

CHANGE HISTORY

First released in Issue 5. Included for alignment with the POSIX Threads Extension.

Issue 6

The pthread_join() function is marked as part of the Threads option.

IEEE Std 1003.1-2001/Cor 2-2004, item XSH/TC2/D6/97 is applied, updating the ERRORS section so that the [EINVAL] error is made optional and the words "the implementation has detected" are removed from it.

Issue 7

The pthread_join() function is moved from the Threads option to the Base.

Austin Group Interpretation 1003.1-2001 #142 is applied, removing the [ESRCH] error condition.

The [EINVAL] error for a non-joinable thread is removed; this condition results in undefined behavior.

The [EDEADLK] error for the calling thread is removed; this condition results in undefined behavior.

Issue 8

Austin Group Defect 792 is applied, changing "a thread that has exited but remains unjoined" to "a zombie thread".

Austin Group Defect 1302 is applied, updating the page to account for the addition of <threads.h> interfaces.

End of informative text.

 

return to top of page

UNIX? is a registered Trademark of The Open Group.
POSIX? is a Trademark of The IEEE.
Copyright ? 2001-2024 The IEEE and The Open Group, All Rights Reserved
[ Main Index | XBD | XSH | XCU | XRAT ]

椴树是什么树 爸爸的哥哥叫什么 可喜可贺是什么意思 香芋是什么 马上好药膏主治什么
痛风吃什么药止痛最快 任督二脉是什么意思 男性尿道痒吃什么药 溪字五行属什么 贫血吃什么补
四月初五是什么星座 金丝雀是什么意思 脑梗都有什么症状 pr在医学上是什么意思 便秘吃什么通便
石榴什么时候成熟 草长莺飞是什么生肖 肺心病吃什么药 斯凯奇鞋是什么档次 20至30元什么烟最好抽
葛粉吃了有什么好处luyiluode.com 羊水是什么颜色的hcv7jop5ns5r.cn 为什么尿液一直是黄的hcv9jop3ns1r.cn 冠脉造影是什么意思hcv8jop9ns0r.cn 吃月饼是什么生肖hcv8jop5ns2r.cn
病毒感冒吃什么药hcv9jop2ns2r.cn 入党有什么好处hcv9jop7ns9r.cn 胎芽是什么意思hcv8jop3ns1r.cn 红楼梦结局是什么dayuxmw.com 玉和翡翠有什么区别hcv8jop7ns6r.cn
8月5日是什么星座hcv9jop7ns3r.cn 糖类抗原724偏高是什么原因hcv8jop5ns6r.cn 流理台是什么hcv9jop3ns8r.cn 寂是什么意思hcv9jop6ns1r.cn 破处是什么意思fenrenren.com
龙鱼是什么鱼hcv7jop9ns6r.cn nt和唐筛有什么区别hcv8jop0ns4r.cn 头顶疼是什么原因引起的hcv9jop1ns6r.cn 耳膜炎是什么原因引起的hcv8jop7ns9r.cn 什么面料不容易皱hcv8jop2ns3r.cn
百度