b8b00688 |
1 | |
92f441a7 |
2 | #include <pthread.h> |
3 | #include <stdio.h> |
4 | #include <unistd.h> |
5 | #include <stdlib.h> |
6 | |
b8b00688 |
7 | #include "lttng_usertrace.h" |
8 | |
92f441a7 |
9 | |
10 | |
11 | void *thr1(void *arg) |
12 | { |
13 | printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
14 | |
15 | while(1) {} |
16 | |
17 | return ((void*)1); |
18 | |
19 | } |
20 | |
21 | void *thr2(void *arg) |
22 | { |
23 | while(1) { |
24 | printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid()); |
25 | sleep(2); |
26 | } |
27 | return ((void*)2); |
28 | } |
29 | |
30 | |
b8b00688 |
31 | int main() |
32 | { |
92f441a7 |
33 | int err; |
34 | pthread_t tid1, tid2; |
35 | void *tret; |
36 | |
37 | err = pthread_create(&tid1, NULL, thr1, NULL); |
38 | if(err!=0) exit(1); |
39 | |
40 | err = pthread_create(&tid2, NULL, thr2, NULL); |
41 | if(err!=0) exit(1); |
b8b00688 |
42 | |
43 | while(1) |
44 | { |
45 | |
46 | } |
92f441a7 |
47 | |
48 | err = pthread_join(tid1, &tret); |
49 | if(err!= 0) exit(1); |
50 | |
51 | err = pthread_join(tid2, &tret); |
52 | if(err!= 0) exit(1); |
b8b00688 |
53 | |
54 | return 0; |
55 | } |