`
umgsai
  • 浏览: 101997 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

Linux创建线程

 
阅读更多

  1. #include"stdio.h"
  2. #include"pthread.h"
  3. #include"unistd.h"
  4. staticshdata=4;
  5. void*create(void*arg)
  6. {
  7. printf("Newpthread......\n");
  8. printf("shareddata=%d\n",shdata);
  9. return(void*)0;
  10. }
  11. intmain()
  12. {
  13. pthread_ttid;
  14. interror;
  15. error=pthread_create(&tid,NULL,create,NULL);
  16. if(error!=0)
  17. {
  18. printf("threadisnotcreated...\n");
  19. return-1;
  20. }
  21. printf("mainpidis%d\n",getpid());
  22. sleep(1);
  23. printf("线程创建成功!\n");
  24. return0;
  25. }

本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/702536

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics