8 #define MAX_NUMS 100000
10 void* producer(void* arg
)
12 queue_t
* queue
= (queue_t
*)arg
;
14 for(i
= 0; i
< MAX_NUMS
; ++i
)
21 void* consumer(void* arg
)
23 queue_t
* queue
= (queue_t
*)arg
;
25 for(i
= 0; i
< MAX_NUMS
; ++i
)
27 printf("got %d from producer\n", queue_pop(queue
));
32 int main(int argc
, char* argv
[])
34 pthread_t prod_thr
, cons_thr
;
35 pthread_cond_t valid_root
;
36 pthread_mutex_t mx_cond
;
40 pthread_create(&cons_thr
, NULL
, producer
, &myqueue
);
41 pthread_create(&prod_thr
, NULL
, consumer
, &myqueue
);
44 queue_clear(&myqueue
);