69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <pthread.h>
pthread_t tid;
void *fun()
{
FILE* pf = fopen("test", "ab");
while(1)
{
fprintf(pf, "aaaa\n");
sleep(5);
fflush(pf);
}
}
int aa()
{
pthread_create(&tid, NULL, fun, NULL);
}
int main()
{
aa();
//daemon注释打开线程就自动的退出了
//daemon(0,0);
pthread_join(tid, NULL);
}