I have a program which is creating two threads but all of this is done in a single c program here is the code
#include<pthread.h>
#include<stdio.h>
#include<stdlib.h>
void * thread1()
{
int i=0;
while(1)
{
printf("%d Hello!!\n", i);
i++;
}
}
void * thread2()
{
int j;
while(1)
{
printf("%d How are you?\n", j);
j++;
}
}
int main()
{
pthread_t tid1,tid2;
pthread_create(&tid1, NULL, thread1, NULL);
pthread_create(&tid2, NULL, thread2, NULL);
pthread_join(tid1,NULL);
pthread_join(tid2,NULL);
return 0;
}
now if
void * thread1()
{
int i=0;
while(1)
{
printf("%d Hello!!\n", i);
i++;
}
}
is defined in another program for example mythread1.c
and
void * thread2()
{
int j;
while(1)
{
printf("%d How are you?\n", j);
j++;
}
}
is defined in another c program for example mythread2.c then how can i call these in my test.c program
test.c
int main()
{
pthread_t tid1,tid2;
pthread_create(&tid1, NULL, thread1, NULL);
pthread_create(&tid2, NULL, thread2, NULL);
pthread_join(tid1,NULL);
pthread_join(tid2,NULL);
return 0;
}
Please guide me is there any way to do this using Linux system call!