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() {
|
2023-08-25 23:36:26 +00:00
|
|
|
{char string[] = "main thread: before!\n";
|
2023-08-15 08:54:02 +00:00
|
|
|
fwrite(string, 1, sizeof string-1, stdout);}
|
2023-08-25 23:36:26 +00:00
|
|
|
|
2023-08-15 08:54:02 +00:00
|
|
|
thrd_t thrd;
|
|
|
|
thrd_create(&thrd, thrd_func, NULL);
|
2023-08-25 23:36:26 +00:00
|
|
|
|
2023-08-15 08:54:02 +00:00
|
|
|
{char string[] = "main thread: after!\n";
|
|
|
|
fwrite(string, 1, sizeof string-1, stdout);}
|
2023-08-25 23:36:26 +00:00
|
|
|
for(;;);
|
2023-08-15 08:54:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|