mercredi 15 février 2017

Which Design Pattern to use in this multi-threaded scenario?

I have 3 algorithms - let's call them A, B, C. Each of these have their own get/set methods e.g. A might have getA()/setA(), B might have getB()/setB(), etc. 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. This 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 know which algorithm instance is passed to it as an argument and accordingly which get/set method to execute?

P.S. I'm using Java.

Aucun commentaire:

Enregistrer un commentaire