I've been trying to work with threads and have an issue I cant seem to fix. I'm trying to spawn a thread from a member function that takes parameters however I have yet to be able to get it to not throw errors.
Heres what I have
ArraySorter s;
char *arr1, *arr2, *arr3;
arr1 = new char[MAXSIZE];
arr2 = new char[MAXSIZE];
arr3 = new char[MAXSIZE];
srand(time(NULL));
for (int i = 0; i < MAXSIZE; i++)
{
arr1[i] = arr2[i] = arr3[i] = rand() % MAXSIZE;
}
thread t1(&ArraySorter::InsertionSort, &s, arr1, MAXSIZE);
thread t2(&ArraySorter.MergeSort, arr2, MAXSIZE);
thread t3(&s.QuickSort, arr3, MAXSIZE);
To be clear all my sorting algorithms take a char * and integer in that order, All 3 ways of spawning the threads above do not work and I'm at a loss since I've tried the solutions I've found.
Declarations:
static void InsertionSort(int* arr, int n, int startIndex, int gap);
static void InsertionSort(int* arr, int n);
static void MergeSort(int* arr, int n);
static void QuickSort(int* arr, int n);
static void ShellSort(int* arr, int n, int* gapVals, int gapValsCount);
static void QuickSort(int *arr, int high, int low);
static int GetPivot(int *arr, int high, int low);
static void MergeArray(int *arr, int high, int mid, int low);
static void MergeSort(int *arr, int high, int low);