- 论坛徽章:
- 0
|
main.c函数如下:
#include "time_pthread.h"
2 #include "water_pthread.h"
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <sys/types.h>
7 #include <pthread.h>
8
9
10 pthread_cond_t g_collect_info = PTHREAD_COND_INITIALIZER;
11 pthread_mutex_t g_condition_mutex = PTHREAD_MUTEX_INITIALIZER;
12
13 int main(int argc, char **argv)
14 {
15 pthread_t id1, id2, id3;
16 int ret1, ret2, ret3;
17 // extern void water_pthread(void);
18
19 // pthread_cond_t g_collect_info = PTHREAD_COND_INITIALIZER;
20 // pthread_mutex_t g_condition_mutex = PTHREAD_MUTEX_INITIALIZER;
21
22 ret1 = pthread_create(&id1, NULL, (void *)time_pthread, NULL);
23 ret2 = pthread_create(&id2, NULL, (void *)water_pthread, NULL);
24
25 pthread_join(id1, NULL);
26 pthread_join(id2, NULL);
27 return 0;
28 } |
|