I want to write a java class that can be instantiated only 5 times just like you have singleton class which have only one instance.
Apart from this the instances should be picked in round robin basis.
Suppose I have a class A. I should be only able to create 5 instances of this class.
Say I have InstanceA_1, InstanceA_2, InstanceA_3, InstanceA_4, InstanceA_5. Whenever I need to use them they should be picked on round robin basis.
Just as
enumis recommended by Effective Java 2nd Edition to implement singleton, this solution also usesenumto implement… quadrupleton?Extending this to quintupleton is self-explanatory.
See also
Related questions