tail head cat sleep
QR code linking to this page

manページ  — PTHREAD_JOIN

名称

pthread_join – スレッド終了の待機

内容

ライブラリ

Reentrant C\~Library (libc_r, -lc_r)

書式

#include <pthread.h>

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

解説

pthread_join() 関数は、対象 thread がまだ終了していない場合には、その対象 thread が終了するまで、呼び出しているスレッドの実行を保留します。

NULL ではない value_ptr 引数を持つ pthread_join() の呼び出しから成功裏に戻った時には、終了したスレッドによって pthread_exit() に渡された値が、 value_ptr によって参照される位置に格納されます。 pthread_join() が成功裏に戻った時には、その対象スレッドは既に終了しています。 同じ対象スレッドを指定した複数で同時の pthread_join() の呼び出しによる結果は、未定義です。 pthread_join() を呼び出しているスレッドが取り消された場合には、その対象スレッドは デタッチされません。

既に終了したが持ち受けされずに残っているスレッドは、 [_POSIX_THREAD_THREADS_MAX] に対してカウントされます。

戻り値

問題がない場合は、 pthread_join() 関数は 0 を返します。 問題がある場合は、そのエラーを示すためにエラー番号が返されます。

エラー

pthread_join() は以下の場合に失敗します。
[EINVAL]
  thread によって指定された値が、 待機されることが可能なスレッドを参照していないことを検出しました。
[ESRCH]
  与えられたスレッド ID, thread によって指定されたものと一致するスレッドを見つけることができません。
[EDEADLK]
  デッドロックを検出しました。または、 thread の値が呼び出しているスレッドを指定しています。

関連項目

wait(2), pthread_create(3)

規格

pthread_join()IEEE Std 1003.1-96 ("POSIX.1") に適合しています。

PTHREAD_JOIN (3) April 4, 1996

tail head cat sleep
QR code linking to this page


このマニュアルページサービスについてのご意見は Ben Bullock にお知らせください。 Privacy policy.

Ken Thompson has an automobile which he helped design. Unlike most automobiles, it has neither speedometer, nor gas gauge, nor any of the other numerous idiot lights which plague the modern driver. Rather, if the driver makes a mistake, a giant “?” lights up in the center of the dashboard. “The experienced driver,” says Thompson, “will usually know what's wrong.”