c11threads

view test.c @ 0:056c9db89e79

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 24 Sep 2012 12:32:42 +0300
parents
children
line source
1 #include <stdio.h>
2 #include "c11threads.h"
4 void tfunc(void *arg);
6 int main(void)
7 {
8 int i;
9 thrd_t threads[4];
11 for(i=0; i<4; i++) {
12 thrd_create(threads + i, tfunc, (void*)(long)i);
13 }
15 for(i=0; i<4; i++) {
16 thrd_join(threads[i], 0);
17 }
19 return 0;
20 }
22 void tfunc(void *arg)
23 {
24 int num = (long)arg;
25 xtime dur;
27 printf("hello from thread %d\n", num);
29 dur.sec = 4;
30 dur.nsec = 0;
31 thrd_sleep(&dur);
33 printf("thread %d done\n", num);
34 }