{"id":3397,"date":"2018-11-21T18:29:18","date_gmt":"2018-11-21T10:29:18","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3397"},"modified":"2018-11-21T18:29:18","modified_gmt":"2018-11-21T10:29:18","slug":"jvm-%e4%b8%ad%e9%9d%99%e6%80%81%e5%8f%98%e9%87%8f%e7%9a%84%e4%bc%98%e5%85%88%e6%89%a7%e8%a1%8c%e9%a1%ba%e5%ba%8f%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3397","title":{"rendered":"JVM \u4e2d\u9759\u6001\u53d8\u91cf\u7684\u4f18\u5148\u6267\u884c\u987a\u5e8f\uff01"},"content":{"rendered":"<p>\n\t1+1=2\uff0c\u5f88\u7b80\u5355\u3002\u5927\u5bb6\u90fd\u61c2\uff01\u4f46\u662f\u4f60\u770b\u770b\u73b0\u5728\u7684\u5e7c\u513f\u56ed\u5927\u73ed\u3001\u5c0f\u5b66\u751f\u7684\u4f5c\u4e1a\u9898\uff0c\u6709\u591a\u5c11\u4f60\u4f1a\u505a\u51fa\u6765\uff0c\u6216\u8005\u662f\u4e00\u773c\u5c31\u770b\u4f5c\u51fa\u7b54\u6848\u6765\uff1f\n<\/p>\n<p>\n\t\u4e0d\u5938\u5f20\u7684\u8bf4\uff0c\u5f88\u591a\u5bb6\u957f\u90fd\u88ab\u6253\u8d25\u6765\u3002\u76f4\u5230\u4f60\u8ba4\u8f93\uff0c\u6000\u7591\u4eba\u751f\u3002\n<\/p>\n<p>\n\t\u7b80\u5355\u7684\u77e5\u8bc6\uff0c\u53ef\u4ee5\u6c47\u603b\u51fa\u4f1f\u5927\u7684\u547d\u9898\u3002\u4eca\u5929\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u770b\u770b\u6253\u8d25\u4e86\u65e0\u6570\u4eba\u7684\u9759\u6001\u53d8\u91cf\u52a0\u8f7d\u6267\u884c\u987a\u5e8f\u9762\u8bd5\u9898\uff01\n<\/p>\n<p>\n\t\u9996\u5148\uff0c\u8bf4\u660e\u4e00\u70b9\u3002\u8fd9\u7bc7\u6587\u7ae0\u662f\u6765\u81ea\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7\u91cc\u7684\u4e00\u4e2a\u7fa4\u53cb\u7684\u6295\u7a3f\u3002\u4ed6\u770b\u8fc7\u6211\u5f88\u591a\u6587\u7ae0\uff0c\u52a0\u8fc7\u6211\u5fae\u4fe1\u3001\u5fae\u535a\u3001\u65f6\u523b\u5173\u6ce8\u7740\u6211\u7684\u7f51\u7ad9\u3002\u4ed6\u53d1\u7ed9\u6211\u7684\u6587\u6863\u4e2d\u6709\u5f88\u591a\u77e5\u8bc6\u70b9\uff0c\u4eca\u5929\u6211\u5148\u62bd\u4e00\u4e2a\u6765\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\n<\/p>\n<p>\n\t\u5370\u8c61\u4e2d\uff0cJVM \u4e2d\u9759\u6001\u53d8\u91cf\u7684\u4f18\u5148\u6267\u884c\u987a\u5e8f\u53ef\u4ee5\u5f52\u7eb3\u603b\u7ed3\u5982\u4e0b\uff1a\n<\/p>\n<blockquote>\n<p>\n\t\t\u7236\u7c7b static \u5757 -&gt; \u5b50\u7c7b static \u5757 -&gt; \u7236\u7c7b{}\u5757 -&gt; \u7236\u7c7b\u6784\u9020\u51fd\u6570 -&gt; \u5b50\u7c7b{}\u5757 -&gt; \u5b50\u7c7b\u6784\u9020\u51fd\u6570\u3002\n\t<\/p>\n<\/blockquote>\n<p>\n\tstatic \u4fee\u9970\u7684\u53d8\u91cf\u548c static \u5757\u5177\u6709\u4e00\u6837\u7684\u4f18\u5148\u7ea7\uff0c\u6545\u4e24\u8005\u5177\u6709\u524d\u540e\u987a\u5e8f\u3002\n<\/p>\n<p>\n\t\u8bb0\u4f4f\u4e0a\u9762\u7684\u6267\u884c\u987a\u5e8f\u540e\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u770b\u4e00\u4e2a\u5c0f\u6d4b\u8bd5\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\npublic class Test{\r\n    private static Test tester = new Test(); \r\n    private static int count1;                 \r\n    private static int count2 = 2;           \r\n    public Test(){                          \r\n        count1++;\r\n        count2++;\r\n        System.out.println(&quot;&quot; + count1); \r\n \tSystem.out.println(&quot;&quot; + count2);  \r\n    }  \r\n    public static Test getTester(){\r\n        return tester;  \r\n    }  \r\n    \/\/ \u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n    public static void main(String[] args){  \r\n        Test.getTester();\r\n\tSystem.out.println(&quot;&quot; + count1); \r\n        System.out.println(&quot;&quot; + count2); \r\n    }  \r\n}<\/pre>\n<p>\n\t\u73b0\u5728\u4f60\u81ea\u5df1\u8ba1\u7b97\u4e00\u4e0b\u8f93\u51fa\u7ed3\u679c\uff0c\u770b\u770b\u6709\u591a\u5c11\u4eba\u5b8c\u5168\u505a\u5bf9\uff01\n<\/p>\n<p>\n\t\u5176\u5b9e\u6211\u4eec\u516c\u53f8\u5728\u9762\u8bd5\u7684\u65f6\u5019\uff0c\u4e5f\u6709\u8fd9\u5957\u9898\uff0c\u5b8c\u5168\u505a\u5bf9\u7684\u4e0d\u591a\u3002\u540e\u6765\u5c31\u964d\u4f4e\u4e86\u8981\u6c42\uff0c\u53ea\u8981\u80fd\u89e3\u91ca\u51fa\u5927\u6982\u7684\u6267\u884c\u8fc7\u7a0b\u5c31\u7b97\u8fc7\uff01\n<\/p>\n<p>\n\t\u73b0\u5728\u6211\u516c\u5e03\u7b54\u6848\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\n1\r\n1\r\n1\r\n2<\/pre>\n<p>\n\t\u73b0\u5728\u6211\u4eec\u6765\u590d\u76d8\uff01\n<\/p>\n<p>\n\tJAVA \u7c7b\u9996\u6b21\u88c5\u5165\u65f6\uff0c\u5f00\u59cb\u52a0\u8f7d\u9759\u6001\u53d8\u91cf\u548c\u9759\u6001\u5757\uff0c\u4e5f\u5c31\u662f\u8bf4\u4f1a\u9996\u5148\u4e3a\u9759\u6001\u533a\u57df\u5206\u914d\u5185\u5b58\u7a7a\u95f4\uff0c\u6b64\u65f6 tester\u3001count1\u3001count2 \u90fd\u5df2\u7ecf\u5206\u914d\u7a7a\u95f4\uff0c\u5176\u4e2d tester \u4e3a\u4e00\u4e2a\u5f15\u7528\u7a7a\u95f4\uff0ccount1\u3001count2 \u4e3a\u9ed8\u8ba4\u503c 0\u3002\n<\/p>\n<p>\n\t\u7b2c\u4e8c\u6b65\u5f00\u59cb\u6267\u884c private static Test tester = new Test() \u8fd9\u6bb5\u4ee3\u7801\uff0c\u8c03\u7528\u6784\u9020\u5668\u6253\u5370\u51fa count1\u3001count2 \u5206\u522b\u4e3a 1 \u548c 1 \u3002\n<\/p>\n<p>\n\t\u7136\u540e\u4f9d\u6b21\u6267\u884c\u4e00\u4e0b\u4ee3\u7801 private static int count1; private static int count2 = 2; \u6b64\u65f6\uff0ccount2 \u88ab\u91cd\u7f6e\u4e3a 2\uff0c\u56e0\u6b64\u5982\u679c\u6b64\u65f6\u518d\u6b21\u6253\u5370\u7684\u8bdd count1\u3001count2 \u7684\u503c\u5e94\u8be5\u4e3a 1 \u548c 2\u3002&nbsp;\n<\/p>\n<p>\n\t\u6700\u540e\uff0c\u611f\u8c22 MD \u7684\u6295\u7a3f\uff0c\u4ed6\u5728\u7fa4\u91cc\u4e5f\u5f88\u6d3b\u8dc3\uff0c\u611f\u8c22\u4ed6\uff01\u4ee5\u540e\u6211\u4eec\u8fdb\u884c\u4ed6\u7684\u5185\u5bb9\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3397\">JVM \u4e2d\u9759\u6001\u53d8\u91cf\u7684\u4f18\u5148\u6267\u884c\u987a\u5e8f\uff01<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>1+1=2\uff0c\u5f88\u7b80\u5355\u3002\u5927\u5bb6\u90fd\u61c2\uff01\u4f46\u662f\u4f60\u770b\u770b\u73b0\u5728\u7684\u5e7c\u513f\u56ed\u5927\u73ed\u3001\u5c0f\u5b66\u751f\u7684\u4f5c\u4e1a\u9898\uff0c\u6709\u591a\u5c11\u4f60\u4f1a\u505a\u51fa\u6765\uff0c\u6216\u8005\u662f\u4e00\u773c\u5c31\u770b\u4f5c\u51fa [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[731,472,546,62,410],"class_list":["post-3397","post","type-post","status-publish","format-standard","hentry","category-java","tag-jvm","tag-rest","tag-546","tag-62","tag-410"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3397"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3397\/revisions"}],"predecessor-version":[{"id":3398,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3397\/revisions\/3398"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}