日期:2014-05-16 浏览次数:20707 次
#include <stdio.h> #include <pthread.h> #include <unistd.h> #include <stdlib.h> void* thread(void*) { int i; char *uargv; for(i=0;i<30;i++) printf("This is a pthread.\n"); return (void*)uargv; } int main(void) { pthread_t id; int i,ret; ret=pthread_create(&id,NULL,&thread,NULL); /*if(ret!=0){ printf ("Create pthread error!\n"); exit (1); }*/ for(i=0;i<30;i++) printf("This is the main process.\n"); pthread_join(id,NULL); return (0); }