- #include"stdio.h"
- #include"pthread.h"
- #include"unistd.h"
- staticshdata=4;
- void*create(void*arg)
- {
- printf("Newpthread......\n");
- printf("shareddata=%d\n",shdata);
- return(void*)0;
- }
- intmain()
- {
- pthread_ttid;
- interror;
- error=pthread_create(&tid,NULL,create,NULL);
- if(error!=0)
- {
- printf("threadisnotcreated...\n");
- return-1;
- }
- printf("mainpidis%d\n",getpid());
- sleep(1);
- printf("线程创建成功!\n");
- return0;
- }
本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/702536