I have 3 algorithms - let's call them A, B, C. Each of these have their own getter and setter methods e.g. A
might have getA()
/setA()
same goes for B and C.
There is a MainDriver
class which creates an instance of either A, B, or C depending on what is passed as a command line argument to this MainDriver
class.
MainDriver
class creates multiple threads to execute the methods of the algorithm whose instance is created. Thus, when this algorithm instance is created, it passes this instance to a class that extends the Thread class so that each individual thread may execute public methods of that algorithm.
Now my question is which Design Pattern should I use to implement this architecture?
How will the thread class knows which algorithm instance is passed to it as an argument and accordingly which getter and setter method to execute?
To start with you can create an hierarchy for all your algirithms. e.g. BaseAlgo is interface and all concrete Algos will implement the same.
Your Thread subclass can refer to BaseAlgo("has a relationship") and you can invoke methods on the concrete Algo object that you pass to it.