Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

threadpool

C 语言栈式线程池

特性

  • 动态扩展、缩减线程池规模
  • 适用于 fork 产生的子进程

示例

./example/whoami.c

#include <unistd.h>
#include <stdio.h>
#include "../src/threadpool.h"

void *
whoami(void *_ __attribute__ ((__unused__))) {
    printf("I am %zd\n", pthread_self());
    return NULL;
}

int
main(void) {
    // 新建线程池,常备线程数:4
    threadpool.init(4);

    for (int i = 0; i < 10; i++) {
        threadpool.add(whoami, NULL);
    }

    sleep(1);
    return 0;
}

编译

cd example &&
cc -O2 -lpthread whoami.c ../src/threadpool.c -o whoami     

Comments ( 0 )

Sign in for post a comment

About

C 语言栈式线程池 spread retract
C
GPL-2.0
Cancel

Releases

No release

threadpool

Contributors

All

Activities

load more
can not load any more