I have existing design of sort of "singleton" implementation with static constructor. I want to be able to destroy and recreate new instance.
Can this be done without changing the base design?
This is simplified prototype:
public static void main(String[] args) { ClassA.doWork(); ClassA.destruct(); ClassA.doWork(); // <--I need new instance here } public class ClassA { private static ClassA inst = new ClassA(); protected ClassA() { //init } public static void doWork(){ //do work } public static void destruct(){ inst = null; } }