It is important to understand that the destructor is called just prior to garbage collection.It is not called when a variable containing a reference to an object goes out of scope, for example. (This differs from destructors in C++, which are called when an object goes out of scope.) This means that you cannot know precisely when a destructor will be executed. Furthermore, it is possible for your program to end before garbage collection occurs, so a destructor might not get called at all.




















本文转自cnn23711151CTO博客,原文链接: http://blog.51cto.com/cnn237111/467666 ,如需转载请自行联系原作者