Thread Programming Ch6
Thread Programming Ch6
1 2
3 4
5 6
5 6
1
2/28/2019
7 8
7 8
• It returns the new thread ID via the tid argument. • This Function is used by a thread to terminate. The
• The attr parameter is used to set thread return value is passed as a pointer.
attributes, NULL for the default values.
pthread_join (tid, value_ptr);
• The start_routine is the C routine that the thread
will execute once it is created. • The pthread_join() subroutine blocks the calling thread
until the specified threadid thread terminates.
• A single argument may be passed to • Return 0 on success, and negative on failure. The
start_routine via arg. It must be passed by returned value is a pointer returned by reference. If you
reference as a pointer cast of type void. do not care about the return value, you can pass NULL
for the second argument.
9 10
9 10
11 12
2
2/28/2019
13 14
15 16
17 18
3
2/28/2019
19 20
References
• pthread libraries
https://www.cs.cmu.edu/afs/cs/academic/class/1
5492-f07/www/pthreads.html
21