I wanted to write the brute force algorithm for string matching by multithreading.
I have made the program by using a single thread.
In multithreading sample code, I have initialised the no. of threads to be strlen(text)-strlen(pattern).
I do the matching in the ThreadFunc.
Do I have to divide the text(A char array)into arrays of strlen(pattern)? If yes, Should i make a separate function for that?
How do I pass both the pattern and the divided text array in the beginthreadex() function?
Kindly help...
HANDLE hth;
HANDLE threadArray[100];
long numberofthreads;
unsigned uiThread1ID;
int x=10;
cout<<"Enter the number of threads to be initialised\n";
cin>>numberofthreads;
for(int i=0; i<numberofthreads;i++)
{
hth = (HANDLE)_beginthreadex( NULL, // security
0, // stack size
ThreadFunc,
&x, // arg list
CREATE_SUSPENDED, // so we can later call ResumeThread()
&uiThread1ID );
if ( hth == 0 )
printf("Failed to create thread 1\n");
threadArray[i]= hth;
}