I was writing a small program to create a thread but i noticed that output is not coming if remove "pthread_exit(N ULL);" statement in main,but if i replace it output is coming.Can someone explain the reason.
Code:
#include<stdio.h>
#include<pthread.h>
void *thread(void *t)
{
int i=10;
while(i)
{
printf("%d",i);
i--;
}
pthread_exit(NULL);
}
int main()
{
int rc;
pthread_t t;
rc=pthread_create(&t,NULL,thread,NULL);
if(rc)
{
printf("error:%d",rc);
return(-1);
}
pthread_exit(NULL);
}
Comment