Linux threads are not working in ubuntu
Hi guys! This is vamsi krishna from india.
I'm using ubuntu 10.10.
I am trying to write a multithread program on ubuntu using C. My program is compiled fine. But only main thread is working but not the new thread. I suspect pthread_create might be failing, but it's fine. Could anybody please let me know the problem. It is the same case with centos also.
my program is:
/**********************************************************
** create.c program starts here **/
#include <stdio.h>
#include <pthread.h>
void *thFun(void *arg)
{
printf("creating new thread \n");
}
int main()
{
pthread_t th;
if(pthread_create(&th, NULL, thFun, NULL))
{
perror("create");
return;
}
printf("main\n");
}
/************************end*****************************/
compilation:
gcc -D_REENTRANT -g -Wall create.c -lpthread
I searched over net for the problem but, I couldn't get any solution in this regards.
Please get me a solution for this.
Thanks in advance.
|