2
0

hello-thread.cpp 393 B

123456789101112131415161718192021
  1. /*
  2. g++ hello-thread.cpp ../../objs/st/libst.a -g -O0 -o hello-thread && ./hello-thread
  3. */
  4. #include <stdio.h>
  5. #include "../../objs/st/st.h"
  6. void* foo(void *args) {
  7. for (int i = 0; ; i++) {
  8. st_sleep(1);
  9. printf("#%d: main: working\n", i);
  10. }
  11. return NULL;
  12. }
  13. int main() {
  14. st_init();
  15. st_thread_create(foo, NULL, 0, 0);
  16. st_thread_exit(NULL);
  17. return 0;
  18. }