fork(9) download
  1. #include <stdio.h>
  2. #include <pthread.h>
  3.  
  4. void* worker(void* arg){
  5. printf("hello, I'm a threading \n");
  6. }
  7.  
  8. int main(){
  9. pthread_t tid;
  10. int ret;
  11.  
  12. ret = pthread_create(&tid, NULL, worker, NULL);
  13. if(ret != 0){
  14. printf("error: 线程创建失败\n");
  15. return -1;
  16. }
  17. printf("the thread id is %lu \n",tid);
  18.  
  19. pthread_join(tid, NULL);
  20. return 0;
  21. }
Success #stdin #stdout 0s 5396KB
stdin
Standard input is empty
stdout
我是父进程,我的pid是 3173 
我是子进程,我的pid是 3213