pthread地獄 part 2 (232レス)
上下前次1-新
113(1): 93 2008/07/24(木)09:46 AAS
複数のワーカースレッドの終了を待つロジックを書いてみた。
/* 全てのワーカースレッドの終了を待つ */
pthread_mutex_lock(&m_end);
while (0 != thread_num) {
while(NULL == thr_end) {
pthread_cond_wait(&c_end, &m_end);
}
nrc = pthread_join(thr_end, NULL);
if (0 == nrc) {
fprintf(stdout, "thread %5d is exited...\n", thr_end);
--thread_num;
thr_end = NULL;
}else{
fprintf(stdout, "Error pthread_join() return %d\n", nrc);
}
pthread_cond_broadcast(&c_end);
}
pthread_mutex_unlock(&m_end);
fprintf(stdout, "ALL thread is exited... thread_num=%d\n", thread_num);
上下前次1-新書関写板覧索設栞歴
あと 119 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.016s