#include
#include
void *mythread1(void *argc)
{
printf("creat the new thread............\n");
//return (void *)8;
//pthread_exit((void *)8);
exit(0);
}
int main(int argc,char * argv[])
{
int ret=0;
pthread_t id1;
void *temp;
ret=pthread_create(&id1,NULL,(void*)mythread1,NULL);
printf("try to creat a thread!\n");
if(ret)
{
printf("creat a thread error!\n");
return -1;
}
ret=pthread_join(id1,&temp);
if(ret)
{
printf("creat a thread error!\n");
return -2;
}
printf("thread is exit code %d!\n",(int) tmp);
return 0;
}
以上是国嵌教学视频的一段代码,编译会出错。
作如下修改:将exit(0)该为_exit(0)即可!
txgc_wm 于 2011-03-02 19:22:34发表:
5# qq22049023
国嵌的嵌入式视频!
qq22049023 于 2011-03-02 16:19:17发表:
你看的是什么教材,网络的能给一份吗,3q
Olcevt 于 2011-03-01 08:46:14发表:
路过看看
txgc_wm 于 2011-03-01 00:11:41发表:
今天完成了linux中线程编程的基础部分!
动手做后的感觉确实不一般。以后继续努力!
txgc_wm 于 2011-02-28 23:08:30发表:
在写code的时候,一定要在英文的状态下,否则执行编译会有出错。有些情况下,根本检查不出错误所在!