Java How to destroy Singleton instance -


i have singleton created that

private static class singletonholder {      public static singleton instance = new singleton(); }  public static singleton getinstance() {     return singletonholder.instance; } 

i'd reset singleton instance @ time. (i'm sure @ time safe reset singleton instance). tried remove final specifier , set instance null when want reset problem how instance (it remain null)

another question is safe remove final specifier inside singletonholder.

thanks

if really need reset singleton instance (which doesn't makes sense actually) wrap inner members in private object, , reinitialize via explicit initialize() , reset() methods. way, can preserve singleton istance , provide kind of "reset" functionality.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -