linux c编程问题

来源:互联网 发布:java开发聊天室 编辑:程序博客网 时间:2024/05/17 03:30

今天写了一个程序。主要代码如下

 

void test(int * i)
{
        while(1)
        {
                printf("****************");
        }
}

void main()

{

        pthread_t pth_io_read;
        ret = pthread_create(&pth_io_read, NULL, (void *)test,&fd);

        return 0;
}

发现程序运行居然不打印***********,后来才发现它作为可执行程序,在main函数运行完后。

对应的线程也就没有了。

 

0 0
原创粉丝点击