the following is a c program where I want to implement an array of thread. there are two thread functions. I want to send an int value inside each function. But the code isn't giving any output. sample program:
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
void * threadFunc1(void * arg)
{
int id = *((int *) arg);
printf("Inside threadfunc2 for thread %d",id)
}
void * threadFunc2(void * arg)
{
int i= *((int *)arg);
printf("Inside threadfunc2 for thread %d",i)
}
int main(void)
{
pthread_t thread[10];
for(int i=0;i<10;i++)
{
pthread_create(&thread[i],NULL,threadFunc1,(void*)&i ); // want to send the value of i inside each thread
pthread_create(&thread[i],NULL,threadFunc,(void*)&i );
}
while(1);
return 0;
}
Is there anything wrong in the code?