Given an hypothetical utility class that is used only in program setup:
class MyUtils {
private static MyObject myObject = new MyObject();
/*package*/static boolean doStuff(Params... params) {
// do stuff with myObject and params...
}
}
will myObject be garbage collected when it is no longer being used, or will it stick around for the life of the program?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…