ciabatta/tests/threaded.c

26 lines
527 B
C
Raw Normal View History

2023-08-15 08:54:02 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>
int thrd_func(void *arg) {
char string[] = "child thread: ok!\n";
fwrite(string, 1, sizeof string-1, stdout);
// exit(1);
for(;;);
return 0;
}
int main() {
{char string[] = "main thread: before!\n";
2023-08-15 08:54:02 +00:00
fwrite(string, 1, sizeof string-1, stdout);}
2023-08-15 08:54:02 +00:00
thrd_t thrd;
thrd_create(&thrd, thrd_func, NULL);
2023-08-15 08:54:02 +00:00
{char string[] = "main thread: after!\n";
fwrite(string, 1, sizeof string-1, stdout);}
for(;;);
2023-08-15 08:54:02 +00:00
return 0;
}