Hai all,
I have a query regarding the threads in Linux.
I wrote an application using the pthreads where in I was to read & write
asynchronously. The read &* write functions are as follows :
void * read( void * X)
{
int a =0;
while(a< 1000)
{
printf("IN read thread %d\n",a);
a++;
}
pthread_exit(0);
}
void * read( void * X)
{
int b =0;
while(b< 1000)
{
printf("IN write thread %d\n",b);
b++;
}
pthread_exit(0);
}
The Output I get is just a series of 1000 read thread printf statements
and a series of 1000 write thread printf statements. Its like as
follows:-
IN read thread 0
IN read thread 1
IN read thread 2
IN read thread 3
.......
.......
.......
IN read thread 1000
IN write thread 0
IN write thread 1
IN write thread 2
IN write thread 3
.......
.......
.......
IN write thread 1000
Why is this happening?
Why are my threads getting executed one after the other rather than
simultaneously.
Thanks for the help in advance.
Regards,
Mukund jampala