线程池C++.docVIP

  • 1
  • 0
  • 约1.43万字
  • 约 13页
  • 2018-03-13 发布于河南
  • 举报
线程池C

C语言实现简单线程池 有时我们会需要大量线程来处理一些相互独立的任务,为了避免频繁的申请释放线程所带来的开销,我们可以使用线程池。下面是一个C语言实现的简单的线程池。 头文件: 1: #ifndef THREAD_POOL_H__ 2: #define THREAD_POOL_H__ 3:? 4: #include pthread.h 5:? 6: /* 要执行的任务链表 */ 7: typedef struct tpool_work { 8: void* (*routine)(void*); /* 任务函数 */ 9: void *arg; /* 传入任务函数的参数 */ 10: struct tpool_work *next; 11: }tpool_work_t; 12:? 13: typedef struct tpool { 14: int shutdown; /* 线程池是否销毁 */ 15: int max_thr

文档评论(0)

1亿VIP精品文档

相关文档