1 | #include <pthread.h> |
---|---|
2 | #include <stdio.h> |
3 | |
4 | int state_var; |
5 | |
6 | void *thread(void *in) { |
7 | state_var++; // break here |
8 | return NULL; |
9 | } |
10 | |
11 | int main(int argc, char **argv) { |
12 | pthread_t t1, t2; |
13 | |
14 | pthread_create(newthread: &t1, NULL, start_routine: *thread, NULL); |
15 | pthread_join(th: t1, NULL); |
16 | pthread_create(newthread: &t2, NULL, start_routine: *thread, NULL); |
17 | pthread_join(th: t2, NULL); |
18 | |
19 | printf(format: "state_var is %d\n", state_var); |
20 | return 0; |
21 | } |
22 |