testpool.c
来自「linux写的基于epoll技术的通信服务器」· C语言 代码 · 共 38 行
C
38 行
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include "public.h"
#include "tpool.h"
#include "common.h"
void dowork(void *arg)
{
char * ptr=(char *)arg;
sleep(1);
printf("hello world! %s\n",ptr);
/* sleep(1); */
/* lprintf(log,INFO,"hello world %s\n",ptr);*/
}
int main(int argc, char *argv[])
{
tpool_t *pool; /*define a thread pool*/
//daemonize();
logd=log_open("test.log", 0);
pool=tpool_init(100,200,1);
// tpool_add_work(pool,dowork,"test!");
sleep(10);
tpool_destroy(pool,1);
log_close(logd);
pthread_exit(NULL);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?