请大家看一下以下这一段小小的程序, #include <stdio.h> #include <pthread.h> void * ThreadTask(void *arg); int main(void) { int status; char ch; pthread_t MyThread; void *result; status = pthread_create(&MyThread,NULL,ThreadTask,NULL); if(status!=0) printf("thread create error\n"); sleep(3); pthread_cancel(MyThread); printf("come to here\n"); pthread_join(MyThread,&result); printf("exit...........\n"); return; } void *ThreadTask(void *arg) { int a; while(1) { a = 1; sleep(1); } } 它只是运行到向屏幕打印输出"come to here",就死在那里了。。。。 请问到底是什么回事呢?????? 谢谢
|