线程函数没有运行?
代码如下:
#include<pthread.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<errno.h>
void *mypthead(void *arg)
{
     pthread_t pid;      
     pid=pthread_self();
     printf("pthread's id is %lu\n",pid);
     printf("pthread ranning\n\r");      
     pthread_exit(NULL);
}
int main()
{
     pthread_t mythread;
     int ret;      
     ret=pthread_create(&mythread,NULL,mypthead,NULL);
     if(ret!=0)
     {
     	printf("can't ran: %s\n",strerror(errno));
     	exit(-1);
     }      
     return 0;
}
     编译:
gcc selfPthread.c -o pthread -lpthread
运行:
$ ./pthread
运行后终端无输出,请问是什么问题?谢谢~
------解决方案--------------------
编译运行,一切正常。
[zcm@t #10]$ls
a.c  csdn.sql  makefile  socket
[zcm@t #11]$make
gcc -g -o a a.c -lpthread
[zcm@t #12]$./a
pthread's id is 3077655408
pthread ranning
[zcm@t #13]$