こっちがワーカースレッド側

   /* メインスレッドに処理終了を通知 */
   pthread_mutex_lock(&m_end);
   while (NULL != thr_end) {
      pthread_cond_wait(&c_end, &m_end);
   }
   thr_end = pthread_self();
   pthread_cond_broadcast(&c_end);
   pthread_mutex_unlock(&m_end);
   pthread_exit((void *)NULL);