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