Rizin
unix-like reverse engineering framework and cli tools
main.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <unistd.h>
3 
4 #include <uv.h>
5 
6 void hare(void *arg) {
7  int tracklen = *((int *) arg);
8  while (tracklen) {
9  tracklen--;
10  sleep(1);
11  fprintf(stderr, "Hare ran another step\n");
12  }
13  fprintf(stderr, "Hare done running!\n");
14 }
15 
16 void tortoise(void *arg) {
17  int tracklen = *((int *) arg);
18  while (tracklen) {
19  tracklen--;
20  fprintf(stderr, "Tortoise ran another step\n");
21  sleep(3);
22  }
23  fprintf(stderr, "Tortoise done running!\n");
24 }
25 
26 int main() {
27  int tracklen = 10;
28  uv_thread_t hare_id;
29  uv_thread_t tortoise_id;
30  uv_thread_create(&hare_id, hare, &tracklen);
31  uv_thread_create(&tortoise_id, tortoise, &tracklen);
32 
33  uv_thread_join(&hare_id);
34  uv_thread_join(&tortoise_id);
35  return 0;
36 }
int main(int argc, const char **argv)
Definition: main.c:340
void tortoise(void *arg)
Definition: main.c:16
void hare(void *arg)
Definition: main.c:6
pthread_t uv_thread_t
Definition: unix.h:136
UV_EXTERN int uv_thread_join(uv_thread_t *tid)
Definition: thread.c:272
UV_EXTERN int uv_thread_create(uv_thread_t *tid, uv_thread_cb entry, void *arg)
Definition: thread.c:210