glib 线程池

   /**
   * 调用20次线程池
   * 实际线程池中最多有10个线程同时运行
   */
  for (count; count < 20; count++)
  {
    g_thread_pool_push(thread_pool, (gpointer)str, NULL);
  }

  g_thread_num =  g_thread_pool_get_max_threads(thread_pool);

  printf("Max number in the pthread pool: %d\n", g_thread_num);
  g_thread_pool_free(thread_pool, 0, 1);

  return;
}

 

gcc `pkg-config --cflags --libs glib-2.0 gthread-2.0` -o g_thread_pool g_thread_pool.c

你可能感兴趣的:(Linux)