Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pthread_join usage

Tags:

c++

join

pthreads

What happens if i call pthread_join(NULL) ?

like image 315
Zach Avatar asked Jul 28 '26 22:07

Zach


2 Answers

you get a compile time error; pthread_join() expects 2 arguments :)

like image 107
user237419 Avatar answered Jul 30 '26 12:07

user237419


If the first of the two expected arguments to pthread_join() is NULL, anything (bad) can happen at runtime. From the specification at www.opengroup.org: "The behavior is undefined if the value specified by the thread argument to pthread_join() does not refer to a joinable thread."

NULL is accepted for the second argument of pthread_join().

EDIT: Indeed some implementations can specify the behavior. Check man page for pthread_join on your system.

like image 21
Alexey Kukanov Avatar answered Jul 30 '26 12:07

Alexey Kukanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!