1 | #include <sys/types.h> |
---|---|
2 | #include <thread> |
3 | #include <unistd.h> |
4 | |
5 | template <typename T> |
6 | void launcher(T func) { |
7 | auto t1 = std::thread(func); |
8 | auto t2 = std::thread(func); |
9 | |
10 | t1.join(); |
11 | t2.join(); |
12 | } |
13 | |
14 | void g() {} |
15 | |
16 | void f() { |
17 | fork(); |
18 | launcher<>(func: g); |
19 | } |
20 | |
21 | int main() { |
22 | launcher<>(func: f); |
23 | |
24 | return 0; |
25 | } |
26 |