I have a singleton class like below
class A{
private volatile static A a;
//declaration of LinkedHashMap
private A(){
//lot of code that puts values in the map
}
public static A getInstance() {
if (a== null) {
synchronized (A.class) {
if (a== null) {
a = new A();
}
}
}
return a;
}
}
I want to refresh the instance of A at some particular condition. How can I refresh the object without using reflection. If not a good practice,what else I can use to ensure that my map gets refreshed only in my particular condition. In short,I want to refreshed my cached map in particular condition without using reflection or without restarting my server.