当前位置:网站首页>C language pthread_ Join() function
C language pthread_ Join() function
2022-07-22 16:18:00 【Dontla】
man 1 pthread_join
PTHREAD_JOIN(3) Linux Programmer's Manual PTHREAD_JOIN(3)
NAME
pthread_join - join with a terminated thread // Connect to terminated thread
SYNOPSIS
#include <pthread.h>
int pthread_join(pthread_t thread, void **retval);
Compile and link with -pthread.
DESCRIPTION
The pthread_join() function waits for the thread specified by thread to terminate. If that thread has already terminated, then pthread_join() returns immediately. The thread specified by thread must be joinable.
//pthread_join() Function waits for the thread specified by the thread to terminate .
// If the thread has terminated , be pthread_join() Return immediately .
//thread The specified thread must be connectable .
If retval is not NULL, then pthread_join() copies the exit status of the target thread (i.e., the value that the target thread sup‐plied to pthread_exit(3)) into the location pointed to by *retval. If the target thread was canceled, then PTHREAD_CANCELED is placed in *retval.
// If retval Not for NULL, be pthread_join() The exit state of the target thread ( That is, the target thread is provided to pthread_exit(3) Value ) Copied to the *retval Point to .
// If the target thread is cancelled , be PTHREAD_CANCELED Be placed in *retval in .
If multiple threads simultaneously try to join with the same thread, the results are undefined. If the thread calling pthread_join() is canceled, then the target thread will remain joinable (i.e., it will not be detached).
// If multiple threads try to connect with the same thread at the same time , The result is undefined .
// If the pthread_join() The thread of was canceled , Then the target thread will remain available join() state ( That is, it won't detached()).
RETURN VALUE
On success, pthread_join() returns 0; on error, it returns an error number.
// success ,pthread_join() return 0; When something goes wrong , It returns an error number .
ERRORS
EDEADLK
A deadlock was detected (e.g., two threads tried to join with each other); or thread specifies the calling thread.
EINVAL thread is not a joinable thread.
EINVAL Another thread is already waiting to join with this thread.
ESRCH No thread with the ID thread could be found.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
┌───────────────┬───────────────┬─────────┐
│Interface │ Attribute │ Value │
├───────────────┼───────────────┼─────────┤
│pthread_join() │ Thread safety │ MT-Safe │
└───────────────┴───────────────┴─────────┘
CONFORMING TO
POSIX.1-2001, POSIX.1-2008.
NOTES
After a successful call to pthread_join(), the caller is guaranteed that the target thread has terminated.
// On successful call pthread_join() after , The caller can guarantee that the target thread has terminated .
Joining with a thread that has previously been joined results in undefined behavior.
//join() Previously join() Threads of lead to undefined behavior .
Failure to join with a thread that is joinable (i.e., one that is not detached), produces a "zombie thread". Avoid doing this, since each zombie thread consumes some system resources, and when enough zombie threads have accumulated, it will no longer be possible to create new threads (or processes).
// Failed to connect with (joinable) The thread of ( That is, the threads that are not separated ) The connection will produce “ Zombie Threads ”. Avoid doing this , Because each zombie thread will consume some system resources , When enough zombie threads are accumulated , You will no longer be able to create new threads ( Or the process ).
There is no pthreads analog of waitpid(-1, &status, 0), that is, "join with any terminated thread". If you believe you need this functionality, you probably need to rethink your application design.
// No similar to waitpid(-1, &status, 0) Of pthreads, namely “join Any terminated thread ”.
// If you think you need this function , You may need to rethink your application design .
All of the threads in a process are peers: any thread can join with any other thread in the process.
// All threads in the process are equal : Any thread can interact with any other thread in the process join.
EXAMPLE
See pthread_create(3).
SEE ALSO
pthread_cancel(3), pthread_create(3), pthread_detach(3), pthread_exit(3), pthread_tryjoin_np(3), pthreads(7)
COLOPHON
This page is part of release 4.04 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at http://www.kernel.org/doc/man-pages/.
Linux 2015-07-23 PTHREAD_JOIN(3)
Manual page pthread_join(3) line 32/73 (END) (press h for help or q to quit)
边栏推荐
- Glide 源码解析
- [solution] solve the importerror: library "Glu" not found
- Shallow copy, deep copy (implementation mode)
- Soc之按键控制LED
- Is there a 35 year old crisis for hardware engineers?
- Why does the system we developed have concurrent bugs? What is the root cause of concurrent bugs?
- JVM:类加载的双亲委派机制
- PXE网络装机
- C# ftp检测目录是否存在和创建文件夹
- Matlab simulation of BER performance of rs+bch concatenated coding and decoding
猜你喜欢
Matlab simulation of bit error rate performance of RS coding and decoding
傍晚的天空
【js】作用域和作用域链
Docker data management case - MySQL data persistence
Docker数据管理案例——MySQL数据持久保存
Collagen protease loaded albumin composite nanoparticles / bovine serum albumin coated ceria nano artificial enzyme
自动化测试工程师面试简历参考
Word: insert vector diagram with specified color
Dominoes staged: the beginning and end of the three arrow capital crash
sftp创建
随机推荐
『需求优化』使用 postMessage 解决 localStorage 跨域问题
Matlab simulation of bit error rate performance of RS coding and decoding
Jmeter界面字体大小设置方法
NB-IOT的基礎知識
进程和线程面试问题
Les bases de l'IOT - NB
P6327 interval plus interval sin sum
Elephant Swap的LaaS方案迅速崛起,构建全新DeFi2.0协议
Vulkan-官方示例解读-子通道
Mnemonic search
[solution] NPM err! code E401
对接三方支付接口需要满足哪些需求?
第四讲 ssh
科普 | 如何创建一个DAO?
图计算-图简介
BCH编码译码误码率性能matlab仿真
Soc之按键控制LED
The two supply chain centers of HEMA launched the "background" of innovative research and development of multi format commodities
自动化测试工程师面试简历参考
Basic knowledge of nb-iot