1. <tfoot id='RnYI6'></tfoot>

      <legend id='RnYI6'><style id='RnYI6'><dir id='RnYI6'><q id='RnYI6'></q></dir></style></legend>
      • <bdo id='RnYI6'></bdo><ul id='RnYI6'></ul>

      <i id='RnYI6'><tr id='RnYI6'><dt id='RnYI6'><q id='RnYI6'><span id='RnYI6'><b id='RnYI6'><form id='RnYI6'><ins id='RnYI6'></ins><ul id='RnYI6'></ul><sub id='RnYI6'></sub></form><legend id='RnYI6'></legend><bdo id='RnYI6'><pre id='RnYI6'><center id='RnYI6'></center></pre></bdo></b><th id='RnYI6'></th></span></q></dt></tr></i><div id='RnYI6'><tfoot id='RnYI6'></tfoot><dl id='RnYI6'><fieldset id='RnYI6'></fieldset></dl></div>

      <small id='RnYI6'></small><noframes id='RnYI6'>

        Java 什么时候调用 finalize() 方法?

        When is the finalize() method called in Java?(Java 什么时候调用 finalize() 方法?)
        <i id='bxV2s'><tr id='bxV2s'><dt id='bxV2s'><q id='bxV2s'><span id='bxV2s'><b id='bxV2s'><form id='bxV2s'><ins id='bxV2s'></ins><ul id='bxV2s'></ul><sub id='bxV2s'></sub></form><legend id='bxV2s'></legend><bdo id='bxV2s'><pre id='bxV2s'><center id='bxV2s'></center></pre></bdo></b><th id='bxV2s'></th></span></q></dt></tr></i><div id='bxV2s'><tfoot id='bxV2s'></tfoot><dl id='bxV2s'><fieldset id='bxV2s'></fieldset></dl></div>
            <tfoot id='bxV2s'></tfoot>

          • <small id='bxV2s'></small><noframes id='bxV2s'>

                  <tbody id='bxV2s'></tbody>

              • <legend id='bxV2s'><style id='bxV2s'><dir id='bxV2s'><q id='bxV2s'></q></dir></style></legend>

                  <bdo id='bxV2s'></bdo><ul id='bxV2s'></ul>
                • 本文介绍了Java 什么时候调用 finalize() 方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要知道 finalize() 方法在 JVM 中被调用.我创建了一个测试类,该类在通过覆盖调用 finalize() 方法时写入文件.它不被执行.谁能告诉我它没有执行的原因吗?

                  I need to know when the finalize() method is called in the JVM. I created a test class which writes into a file when the finalize() method is called by overriding it. It is not executed. Can anybody tell me the reason why it is not executing?

                  推荐答案

                  一般来说最好不要依赖finalize()来做任何清理等操作

                  In general it's best not to rely on finalize() to do any cleaning up etc.

                  根据 Javadoc(值得一读),它是:

                  According to the Javadoc (which it would be worth reading), it is:

                  当垃圾收集器确定不再有对该对象的引用时,由垃圾收集器对该对象调用.

                  Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

                  正如 Joachim 所指出的,如果对象总是可访问的,这可能永远不会在程序的生命周期中发生.

                  As Joachim pointed out, this may never happen in the life of a program if the object is always accessible.

                  此外,垃圾收集器不能保证在任何特定时间运行.一般来说,我想说的是 finalize() 可能不是一般使用的最佳方法,除非有特定的需要.

                  Also, the garbage collector is not guaranteed to run at any specific time. In general, what I'm trying to say is finalize() is probably not the best method to use in general unless there's something specific you need it for.

                  这篇关于Java 什么时候调用 finalize() 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Maven JAVA_HOME environment variable is not defined correctly, but it is(Maven JAVA_HOME 环境变量未正确定义,但它是)
                  Java System Environment Variable(Java 系统环境变量)
                  Java -classpath option(Java -classpath 选项)
                  Read environment variable in SpringBoot(在 SpringBoot 中读取环境变量)
                  Tomcat 8 - context.xml use Environment Variable in Datasource(Tomcat 8 - context.xml 在数据源中使用环境变量)
                  Issue with JAVA_HOME(JAVA_HOME 的问题)
                  1. <tfoot id='0q9ZY'></tfoot>
                    • <small id='0q9ZY'></small><noframes id='0q9ZY'>

                          <bdo id='0q9ZY'></bdo><ul id='0q9ZY'></ul>
                        • <i id='0q9ZY'><tr id='0q9ZY'><dt id='0q9ZY'><q id='0q9ZY'><span id='0q9ZY'><b id='0q9ZY'><form id='0q9ZY'><ins id='0q9ZY'></ins><ul id='0q9ZY'></ul><sub id='0q9ZY'></sub></form><legend id='0q9ZY'></legend><bdo id='0q9ZY'><pre id='0q9ZY'><center id='0q9ZY'></center></pre></bdo></b><th id='0q9ZY'></th></span></q></dt></tr></i><div id='0q9ZY'><tfoot id='0q9ZY'></tfoot><dl id='0q9ZY'><fieldset id='0q9ZY'></fieldset></dl></div>
                          • <legend id='0q9ZY'><style id='0q9ZY'><dir id='0q9ZY'><q id='0q9ZY'></q></dir></style></legend>
                              <tbody id='0q9ZY'></tbody>