マルチスレッドのプログラミング

指定したスレッドの終了待ち


#include <thread.h>

thread_t tid;
thread_t departedid;
int ret;
int status;

/* スレッド「tid」の終了待ち、status の指定あり */
ret = thr_join(tid, &departedid, (void**)&status);

/* スレッド「tid」の終了待ち、status の指定なし */
ret = thr_join(tid, &departedid, NULL);

/* スレッド「tid」の終了待ち、departedid と status の指定なし */
ret = thr_join(tid, NULL, NULL); 

tid(thread_t) 0 の場合は、thr_join() はプロセス内の切り離されていない任意のスレッドの終了を待ちます。つまり、スレッド識別子を指定しなければ、切り離されていないスレッドのどれかが終了すると thr_join() が復帰します。