{"id":1188,"date":"2017-03-27T17:41:36","date_gmt":"2017-03-27T09:41:36","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1188"},"modified":"2018-11-14T16:30:30","modified_gmt":"2018-11-14T08:30:30","slug":"%e8%af%a6%e8%a7%a3%e4%bd%bf%e7%94%a8-jstack-%e8%b7%9f%e8%b8%aa-java-%e5%bc%82%e5%b8%b8%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1188","title":{"rendered":"\u8be6\u89e3\u4f7f\u7528 jstack \u8ddf\u8e2a java \u5f02\u5e38\u4ee3\u7801"},"content":{"rendered":"<p>\n\t\u6700\u8fd1\u516c\u53f8\u6709\u4e00\u9879\u4e1a\u52a1\u5728\u505a\u6d3b\u52a8\uff0c\u6d41\u91cf\u4e00\u4e0b\u5b50\u5927\u589e\u3002\u6570\u636e\u66b4\u6da8\u4e8680\uff0c\u7cfb\u7edf\u65e0\u6cd5\u652f\u6491\uff0c\u5bfc\u81f4\u4e86\u7a0b\u5e8f\u5185\u5b58\u6ea2\u51fa\uff0c\u7cfb\u7edf\u5b95\u673a\u3002\u67e5\u770b\u65e5\u5fd7\u53d1\u73b0\u662f\u6709\u5185\u5b58\u6ea2\u51fa\u7684\u5f02\u5e38\uff0c\u4eca\u5929\u5c31\u4e3a\u5927\u5bb6\u5206\u4eab\u4e00\u4e0b\u5982\u4f55\u4f7f\u7528 <a href=\"http:\/\/baike.baidu.com\/item\/jstack\" name=\"jstack\" target=\"_blank\" title=\"jstack\">jstack<\/a> \u547d\u4ee4\u6392\u67e5\u5b9a\u4f4d<a href=\"http:\/\/baike.baidu.com\/item\/java\/85979\" name=\"java\" target=\"_blank\" title=\"java\">java<\/a>\u7a0b\u5e8f\u4e2d\u7684\u5f02\u5e38\u4ee3\u7801\u3002\n<\/p>\n<h2>\n\t\u81ea\u9020 java \u5185\u5b58\u6ea2\u51fa\u4ee3\u7801<br \/>\n<\/h2>\n<p>\n\t\u4e3a\u4e86\u8bb2\u6e05\u695a jstack \u7684\u4f7f\u7528\uff0c\u6211\u4eec\u5148\u81ea\u9020\u4e00\u4e2ajava <a href=\"http:\/\/baike.baidu.com\/item\/\u5185\u5b58\u6ea2\u51fa\" name=\"\u5185\u5b58\u6ea2\u51fa\" target=\"_blank\" title=\"\u5185\u5b58\u6ea2\u51fa\">\u5185\u5b58\u6ea2\u51fa<\/a>\u7684\u7a0b\u5e8f\u3002\u7a0b\u5e8f\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\nclass KeylessEntry {\r\n\tstatic class Key {\r\n\t\tInteger id;\r\n\t  \r\n\t\tKey(Integer id) {\r\n\t\t\tthis.id = id;\r\n\t\t}\r\n\t  \r\n\t\t@Override\r\n\t\tpublic int hashCode() {\r\n\t\t\treturn id.hashCode();\r\n\t\t}\r\n\t}\r\n  \r\n\tpublic static void main(String[] args) {\r\n\t\tMap m = new HashMap();\r\n\t\twhile (true)\r\n\t\t\tfor (int i = 0; i &lt; 10000; i++)\r\n\t\t\t\tif (!m.containsKey(i))\r\n\t\t\t\t\tm.put(new Key(i), &quot;Number:&quot; + i);\r\n\t}\r\n}<\/pre>\n<p>\n\t\u5f53\u4f60\u8fd0\u884c\u4e0a\u9762\u7684\u4ee3\u7801\u65f6\uff0c\u4f60\u53ef\u80fd\u4f1a\u671f\u671b\u5b83\u8fd0\u884c\u8d77\u6765\u6c38\u8fdc\u4e0d\u4f1a\u51fa\u95ee\u9898\uff0c\u6bd5\u7adf\u5185\u7f6e\u7684\u7f13\u5b58\u65b9\u6848\u53ea\u4f1a\u589e\u52a0\u523010,000\u4e2a\u5143\u7d20\uff0c\u7136\u540e\u5c31\u4e0d\u4f1a\u518d\u589e\u52a0\u4e86\uff0c\u6240\u6709\u7684key\u90fd\u5df2\u7ecf\u51fa\u73b0\u5728 <a href=\"http:\/\/baike.baidu.com\/item\/Hashmap\" name=\"Hashmap\" target=\"_blank\" title=\"Hashmap\">HashMap<\/a>\u4e2d\u3002\u7136\u800c\uff0c\u4e8b\u60c5\u5e76\u975e\u5982\u6b64\u3002\u5143\u7d20\u5c06\u4f1a\u4e00\u76f4\u589e\u957f\uff0c \u56e0\u4e3aKey\u8fd9\u4e2a\u7c7b\u6ca1\u6709\u5728hashCode()\u540e\u5b9e\u73b0\u4e00\u4e2a\u5408\u9002\u7684equals()\u65b9\u6cd5\u3002\n<\/p>\n<p>\n\t\u8fd0\u884c\u8fd9\u4e2a\u7a0b\u5e8f\u540e\uff0c\u6211\u4eec\u53d1\u73b0\u4e0d\u9700\u8981\u592a\u957f\u7684\u5b9e\u9645\uff0c\u7a0b\u5e8f\u5c31\u62a5\u5185\u5b58\u6ea2\u51fa\u4e86\u3002\u6253\u5f00\u4efb\u52a1\u7ba1\u7406\uff0c\u6b64\u4f8b\u4e2d\uff0c\u627e\u51fajava\u8fdb\u7a0bID\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u4efb\u52a1\u7ba1\u7406\u5668\u4e2d\u67e5\u770bjava\u8fdb\u7a0bid\" src=\"http:\/\/img-bbs.csdn.net\/upload\/201703\/27\/1490606726_896880.png\" style=\"width: 452px;height: 243px\" \/>\n<\/p>\n<p>\n\t\u4f1a\u4e86\u65b9\u4fbf\uff0c\u5927\u5bb6\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4f7f\u7528ProcessExplorer\u627e\u5230ID\u53f7\u4e3a7064\u7684java\u8fdb\u7a0b\u3002\u8fdb\u7a0bID\u4e3a7064\u7684\u5c5e\u6027\u4fe1\u606f\u5728Thread\u6807\u7b7e\u627e\u5230CPU\u5229\u7528\u7387\u7684\u7ebf\u7a0b\u4fe1\u606f\uff0cTID\u4e3a6120\uff0810\u8fdb\u5236\uff09\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"ProcessExplorer \u67e5\u770b\u8fdb\u573a\u7684\u7ebf\u7a0b\u4fe1\u606f\" src=\"http:\/\/img-bbs.csdn.net\/upload\/201703\/27\/1490606979_153762.png\" style=\"width: 473px;height: 375px\" \/>\n<\/p>\n<p>\n\t\u5c06CPU\u5229\u7528\u7387\u9ad8\u7684\u7ebf\u7a0bID 6120\uff0810\u8fdb\u5236\uff09\u8f6c\u6362\u4e3a0x17E8\uff0816\u8fdb\u5236\uff09\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"10\u8fdb\u5236\u8f6c16\u8fdb\u5236\" src=\"http:\/\/img-bbs.csdn.net\/upload\/201703\/27\/1490607072_594124.png\" style=\"width: 412px;height: 376px\" \/>\n<\/p>\n<p>\n\t\u4f7f\u7528jstack\u67e5\u770b\u8fdb\u7a0b7064\u7684\u7ebf\u7a0b\u4fe1\u606f\u3002\u627e\u5230\u7ebf\u7a0b\u53f7\u4e3a0x17E8\u7684\u7ebf\u7a0b\u3002\u547d\u4ee4\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\njstack -l &nbsp;7064<\/pre>\n<p>\n\t<img decoding=\"async\" alt=\"jstack \u5b9a\u4f4d\u5f02\u5e38\u4ee3\u7801\" src=\"http:\/\/img-bbs.csdn.net\/upload\/201703\/27\/1490607223_586325.png\" style=\"width: 459px;height: 391px\" \/>\n<\/p>\n<p>\n\t\u6839\u636e\u63d0\u793a\u7684\u884c\u53f7\uff0c\u6211\u4eec\u5b9a\u4f4d\u5230\u76f8\u5173\u7684\u4ee3\u7801\u3002\u901a\u8fc7\u5206\u6790\u53d1\u73b0\uff0c\u662fmap\u9020\u6210\u7684\u5185\u5b58\u6ea2\u51fa\u3002\n<\/p>\n<p>\n\t\u89e3\u51b3\u65b9\u6cd5\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u548c\u4e0b\u9762\u7684\u793a\u4f8b\u4e00\u6837\u6dfb\u52a0\u4e00\u4e2aequals\u65b9\u6cd5\u5c31\u53ef\u4ee5\u4e86\u3002\u4f46\u662f\u5728\u627e\u5230\u95ee\u9898\u6240\u5728\u4e4b\u524d\uff0c\u4f60\u80af\u5b9a\u5df2\u7ecf\u82b1\u8d39\u4e86\u4e0d\u5c11\u5b9d\u8d35\u7684\u8111\u7ec6\u80de\u3002\n<\/p>\n<pre class=\"brush:java;\">\r\n@Override\r\npublic boolean equals(Object o) {\r\n\tboolean response = false;\r\n\tif (o instanceof Key) {\r\n\t\tresponse = (((Key)o).id).equals(this.id);\r\n\t}\r\n\treturn response;\r\n}<\/pre>\n<p>\n\tjstack \u547d\u4ee4\u5f88\u5b9e\u7528\uff0c\u662fjava\u865a\u62df\u673a\u81ea\u5e26\u7684\u4e00\u79cd\u5806\u6808\u8ddf\u8e2a\u5de5\u5177\u3002\u5b66\u4f1a\u5b83\u5bf9\u4f60\u7684\u804c\u4e1a\u751f\u6daf\u6709\u5f88\u5927\u7684\u5e2e\u52a9\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=1188\">\u8be6\u89e3\u4f7f\u7528 jstack \u8ddf\u8e2a java \u5f02\u5e38\u4ee3\u7801<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u516c\u53f8\u6709\u4e00\u9879\u4e1a\u52a1\u5728\u505a\u6d3b\u52a8\uff0c\u6d41\u91cf\u4e00\u4e0b\u5b50\u5927\u589e\u3002\u6570\u636e\u66b4\u6da8\u4e8680\uff0c\u7cfb\u7edf\u65e0\u6cd5\u652f\u6491\uff0c\u5bfc\u81f4\u4e86\u7a0b\u5e8f\u5185\u5b58\u6ea2\u51fa\uff0c\u7cfb\u7edf\u5b95\u673a\u3002\u67e5\u770b\u65e5 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[945,200,599,600,946],"class_list":["post-1188","post","type-post","status-publish","format-standard","hentry","category-java","tag-jstack","tag-599","tag-600","tag-946"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1188","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=1188"}],"version-history":[{"count":3,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1188\/revisions"}],"predecessor-version":[{"id":3363,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1188\/revisions\/3363"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}