{"id":1458,"date":"2016-12-29T19:55:57","date_gmt":"2016-12-29T11:55:57","guid":{"rendered":"http:\/\/coderbee.net\/?p=1458"},"modified":"2016-12-29T14:57:06","modified_gmt":"2016-12-29T06:57:06","slug":"java-finalize-%e6%96%b9%e6%b3%95%e4%b8%8e%e5%9e%83%e5%9c%be%e5%9b%9e%e6%94%b6","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/java\/20161229\/1458","title":{"rendered":"Java finalize \u65b9\u6cd5\u4e0e\u5783\u573e\u56de\u6536"},"content":{"rendered":"<p>JVM \u5bf9\u4e8e\u8986\u5199\u4e86 <code>Object.finalize()<\/code> \u65b9\u6cd5\u7684\u7c7b\u662f\u5b9e\u4f8b\uff0c\u5728\u5783\u573e\u56de\u6536\u65f6\uff0c\u5148\u653e\u8fdb\u4e00\u4e2a\u961f\u5217\u91cc\uff0c<br \/>\n\u7136\u540e\u7528\u4e00\u4e2a\u7ebf\u7a0b\u6267\u884c\u8fd9\u4e9b\u5b9e\u4f8b\u7684 finalize \u65b9\u6cd5\uff0c\u6700\u540e\u624d\u505a\u5185\u5b58\u56de\u6536\u3002<\/p>\n<p>\u8fd9\u4e2a\u673a\u5236\u7684\u95ee\u9898\u662f\uff1a\u5b83\u4f1a\u5f71\u54cd\u5783\u573e\u56de\u6536\uff0c\u5982\u679c\u5b9e\u73b0\u4e86 finalize \u7684\u5b9e\u4f8b\u5f88\u591a\uff0c\u90a3\u4e48\u56de\u6536\u961f\u5217\u5c31\u4f1a\u5f88\u957f\uff0c\u800c\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b<br \/>\n\u5728\u6267\u884c\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u5bf9\u8c61\u5c31\u4f1a\u56de\u6536\u5f97\u5f88\u6162\u3002<\/p>\n<p>\u6700\u8fd1\u78b0\u5230\u7684\u4e00\u4e2a\u95ee\u9898\u8ddf finalize \u65b9\u6cd5\u6709\u5173\u3002<br \/>\n\u5382\u5546\u63d0\u4f9b\u7684\u4ee3\u7801\u628a <code>javax.sql.Connection<\/code> \u505a\u4e86\u5c42\u5c01\u88c5\uff0c\u8986\u5199\u4e86 <code>finalize<\/code> \u65b9\u6cd5\uff0c\u5728\u91cc\u9762\u628a <code>Connection<\/code> \u5173\u95ed\u4e86\u3002<\/p>\n<p>\u4e00\u4e2a\u540c\u4e8b\u8c03\u7528\u7684\u65b9\u6cd5\u5b9a\u4e49\u662f\u7528\u5c01\u88c5\u7c7b\u4f5c\u4e3a\u5165\u53c2\uff0c\u4ed6\u8c03\u7528\u7684\u65f6\u5019\u662f\u76f4\u63a5 new \u4e86\u4e00\u4e2a\u5c01\u88c5\u7c7b\uff0c\u628a connection \u4f20\u8fdb\u53bb\uff0c\u540e\u7eed\u6570\u636e\u5e93\u64cd\u4f5c\u5c31\u4e0d\u5b9a\u4f4d\u7f6e\u51fa\u73b0\u8fde\u63a5\u5173\u95ed\u7684\u5f02\u5e38\u3002\u539f\u56e0\u5c31\u662f\u8fd9\u4e2a\u4e34\u65f6 new \u51fa\u6765\u7684\u5c01\u88c5\u7c7b\u88ab\u5783\u573e\u56de\u6536\uff0c\u628a connection \u5173\u95ed\u4e86\u3002\u7531\u4e8e\u5783\u573e\u56de\u6536\u7684\u65f6\u95f4\u662f\u4e0d\u786e\u5b9a\u7684\uff0c\u6240\u4ee5\u62a5\u5f02\u5e38\u7684\u65f6\u95f4\u70b9\u4e5f\u4e0d\u786e\u5b9a\u3002<\/p>\n<hr\/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JVM \u5bf9\u4e8e\u8986\u5199\u4e86 Object.finalize() \u65b9\u6cd5\u7684\u7c7b\u662f\u5b9e\u4f8b\uff0c\u5728\u5783\u573e\u56de &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/java\/20161229\/1458\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[264,231],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1458"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=1458"}],"version-history":[{"count":1,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1458\/revisions"}],"predecessor-version":[{"id":1459,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1458\/revisions\/1459"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=1458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=1458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=1458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}