int
main ()
{
  pthread_t sigusr1_thread, sigusr2_thread;

  /* Protect against running forever.  */
  alarm (60);

  signal (SIGUSR1, sigusr1_handler);
  signal (SIGUSR2, sigusr2_handler);
  signal (SIGABRT, sigabrt_handler);

  /* Don't let any thread advance past initialization.  */
  ready = 0;

  pthread_mutex_init (&thread_count_mutex, NULL);
  pthread_cond_init (&thread_count_condvar, NULL);

#define NR_THREADS 2
  pthread_create (&sigusr1_thread, NULL, sigusr1_thread_function, NULL);
  pthread_create (&sigusr2_thread, NULL, sigusr2_thread_function, NULL);
  wait_all_threads_running (NR_THREADS);
  all_threads_running ();

  pthread_kill (pthread_self (), SIGABRT);

  pthread_join (sigusr1_thread, NULL);
  pthread_join (sigusr2_thread, NULL);
  all_threads_done ();

  return 0;
}
int
main (void)
{
  pthread_t forever[NR_THREADS];
  int i;

  pthread_mutex_init (&thread_count_mutex, NULL);
  pthread_cond_init (&thread_count_condvar, NULL);

  for (i = 0; i < NR_THREADS; ++i)
    pthread_create (&forever[i], NULL, forever_pthread, NULL);

  wait_all_threads_running ();
  all_threads_running ();

  return 0;
}
int
main (void)
{
  int i;

  signal (SIGABRT, sigabrt_handler);

  pthread_mutex_init (&thread_count_mutex, NULL);
  pthread_cond_init (&thread_count_condvar, NULL);

  for (i = 0; i < NR_THREADS; ++i)
    pthread_create (&threads[i], NULL, thread_entry, NULL);

  wait_all_threads_running ();
  all_threads_running ();

  return 0;
}