请大家看一下以下这一段小小的程序,
#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",就死在那里了。。。。
请问到底是什么回事呢??????
谢谢
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18