is it possible to pass an already defined function into a pthread?
so for example within my code i am able to define an array size once a user enters an array size(for example user enters 200) it will add the numbers 1-200 to an array , i then have a function that will print the array data into a textfile then another function that will print the array in reverse to the same text file.
I want to have two pthreads that will handle the printArray function and another pthread to handle the printArrayReverse function.
so here is the function for the printArray
void printArray (int size, int a1[] )
{
cout << " Array in order " << endl;
for( int i=0; i< size; ++i)
{
cout << a1[i] << " ";
cout << endl;
cout << "----------------"<<endl;
writeToText(a1[i]);
}
so within my int main
i have my two threads
pthread_t threadOne, threadTwo;
then i want the printArray function to be in this threadOne then my print reverse in threadTwo.
pthread_create(&threadOne, NULL , &thread_function, NULL);
pthread_create(&threadTwo, NULL , &thread_function, NULL);
pthread_join(threadOne,NULL)
pthread_join(threadTwo,NULL)
So basically is it possible to say that if i created a new function called
void* thread_function ()
{
}
could i call the printArray into there?