main.cpp 530 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "thread_pool.h"
using namespace std;
using namespace sccl;

void multiply(const int a, const int b) {
    const int res = a * b;
    printf("%d * %d = %d\n", a, b, res);
}

void* show_id(void* id) {
    int tid = *(int*)id;
    for(int i = 0; i < 1000; ++i) {
        printf("id=%d\n", tid);
    }

    return (void*)0;
}

int main() {
    ThreadPool thread_pool(30);
    for(int i = 1; i < 3; ++i) {
        for(int j = 1; j < 10; ++j) {
            thread_pool.enqueue(multiply, i, j);
        }
    }

    return 0;
}