-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_thread.cpp
More file actions
52 lines (33 loc) · 812 Bytes
/
Copy pathtest_thread.cpp
File metadata and controls
52 lines (33 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include"logging.h"
#include <pthread.h>
void *func_1(void *arg)
{
for(int i = 0; i < 100; i++)
{
ZLOG_INFO("{0:d} x {1:d} = {2:d}", i, i , i * i);
// my_log.my_logger->info("{0:d} x {1:d} = {2:d}", i, i , i * i);
// usleep(100000);
}
return NULL;
}
void *func_2(void *arg)
{
for(int i = 0; i < 100; i++)
{
ZLOG_INFO("{0:d} x {1:d} = {2:d}", i, i , i * i);
// my_log.my_logger->info("{0:d} x {1:d} = {2:d}", i, i , i * i);
// usleep(100000);
}
return NULL;
}
int main()
{
ZLOG::getInstance("./log/", "test.log", 3);
pthread_t thread_1, thread_2;
pthread_create(&thread_1, NULL, func_1, NULL);
pthread_create(&thread_2, NULL, func_2, NULL);
pthread_join(thread_1, NULL);
pthread_join(thread_2, NULL);
// my_log.destroy_logger();
return 0;
}