I am completely lost on how to accomplish what I am doing but ill try to explain here:
I have a class which I create 4 objects from.
Code:
CalcPrime[] calcPrimeObjects = new CalcPrime[NUMBER_OF_THREADS];
for (int x = 0; x < NUMBER_OF_THREADS; x++)
{
calcPrimeObjects[x] = new CalcPrime(STARTING_NUMBER, NUMBER_OF_NUMBERS_TO_CHECK, CONSOLE_OUTPUT);
calcPrimeObjects[x].DeclareStacks();
}
What happens here is that I create all four objects and then run a single method for each object that basically declare all initial values for it.
From here I create a new object from a class that handles my threading.
Code:
ThreadDeclaration threadDeclare = new ThreadDeclaration(
NUMBER_OF_THREADS,
CONSOLE_OUTPUT,
calcPrimeObjects);
As you see I am passing my array of objects along to the thread object.
Within the thread class I have the following
Code:
oThread = new Thread[numThreads];
for (int x = 0; x < numThreads; x++)
{
//oThread[x] = new Thread(objects[x]);
}
This is where I would assign the method to execute to the thread objects. Problem is that you dont have access to that method.
What I am thinking is that I have to create a method that accepts a method and pass it along to start the threads. Or somehow pass along the method reference along with the objects earlier at the constructor.
Sorry if I have the terminology wrong kind of new to this all.