-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesta1.c
55 lines (44 loc) · 919 Bytes
/
testa1.c
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
53
54
55
#include<iostream>
#include<time.h>
//#include<conio.h>
#include<cstdlib>
#include<pthread.h>
#include <unistd.h>
#include <emscripten/emscripten.h>
#include <emscripten/threading.h>
#define NUM 100
using namespace std;
extern "C"
{
void EMSCRIPTEN_KEEPALIVE *show_time(void*)
{
time_t t, val =1;
struct tm* ist;
t = time(NULL);
ist = localtime(&t);
cout<<ist->tm_hour;
cout<<":";
cout<<ist->tm_min;
cout<<":";
cout<<ist->tm_sec;
cout<<":\n";
}
}
int EMSCRIPTEN_KEEPALIVE main()
{
pthread_t th[NUM];
int er;
for(int i=0;i<NUM;i++) {
er = pthread_create(&th[i],NULL,&show_time,( void*)i);
sleep(1);
// clrscr();
if(er)
{
std::cout << "err" << std::endl;
exit(-1);
}
}
//show_time();
pthread_exit(NULL);
return 0;
}