#include"stdio.h" #include"pthread.h" #include"unistd.h" static shdata=4; void *create(void *arg) { printf("New pthread...... "); printf("shared data=%d ",shdata); return(void *)0; } int main() { pthread_t tid; int error; error=pthread_create(&tid,NULL,create,NULL); if(error!=0) { printf("thread is not created... "); return -1; } printf("main pid is %d ",getpid()); sleep(1); printf("线程创建成功! "); return 0; } //本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/702536