最終更新:2021-01-05 (火) 04:31:16 (1208d)  

pthread_join
Top / pthread_join

指定されたスレッドが終了するのを待つ

int pthread_join(pthread_t? th, void **thread_return)

https://linuxjm.osdn.jp/html/glibc-linuxthreads/man3/pthread_join.3.html

pthread_create(&thread_id, NULL, thread_main, (void *)NULL);
pthread_join(thread_id, NULL);

メモ

  • thread_return が NULL でないときには、 th の返り値が thread_return で指し示される領域に格納される。
    • th の返り値は、 pthread_exit(3) に与えられた引数、または PTHREAD_CANCELED( th が取り消しされた場合 ) である。
  • 正常に実行された場合、pthread_join() は 0 を戻します。

メモ

  • 指定したスレッドが終了するまで呼び出しスレッドをブロック

関連