{"id":652,"date":"2019-02-18T22:58:01","date_gmt":"2019-02-18T14:58:01","guid":{"rendered":"http:\/\/www.eait.co\/?p=652"},"modified":"2019-04-05T12:30:44","modified_gmt":"2019-04-05T04:30:44","slug":"java-%e4%b8%ad%e6%96%ad%e7%ba%bf%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=652","title":{"rendered":"java\u2014\u2014\u4e2d\u65ad\u7ebf\u7a0b"},"content":{"rendered":"<pre>\/**\r\n * Created by xabcd on 2019\/2\/18.\r\n *\/\r\npublic class stopThread implements Runnable\r\n{\r\n    public void run()\r\n    {\r\n        try {\r\n            System.out.println(\"\u5728run\uff08\uff09\u65b9\u6cd5\u4e2d\uff0c-\u8fd9\u4e2a\u7ebf\u7a0b\u4f11\u772020\u79d2\");\r\n            Thread.sleep(20000);\r\n            System.out.println(\"\u5728run\uff08\uff09\u65b9\u6cd5\u4e2d\uff0c-\u8fd9\u4e2a\u7ebf\u7a0b\u4f11\u772020\u79d2\");\r\n        }\r\n        catch (InterruptedException i)\r\n        {\r\n            System.out.println(\"\u5728run\u65b9\u6cd5\u4e2d-\u4e2d\u65ad\u7ebf\u7a0b\");\r\n            return;\r\n        }\r\n<span style=\"color: #ff0000;\">\/\/\u6dfb\u52a0finally\u540e\u5c06\u80fd\u591f\u6253\u5370\u51fa\u4e0b\u9762\u4e24\u884c<\/span>\r\n        System.out.println(\"\u5728run\uff08\uff09\u65b9\u6cd5\u4e2d-\u4f11\u7720\u4e4b\u540e\u7ee7\u7eed\u5b8c\u6210\");\r\n        System.out.println(\"\u5728run\uff08\uff09\u65b9\u6cd5\u4e2d-\u6b63\u5e38\u9000\u51fa\");\r\n\r\n    }\r\n    public static void main(String args[])\r\n    {\r\n        stopThread tt = new stopThread();\r\n        Thread t = new Thread(tt);\r\n        t.start();\r\n        try {\r\n            Thread.sleep(20);\r\n        }\r\n        catch (InterruptedException x){}\r\n        System.out.println(\"\u5728main\u65b9\u6cd5\u4e2d=\u4e2d\u65ad\u5176\u5b83\u7ebf\u7a0b\");\r\n        t.interrupt();\r\n\/\/        try {\r\n\/\/            Thread.sleep(1); <span style=\"color: #ff0000;\">\/\/\u5c1d\u8bd5\u5c06\u6b64\u5757\u6ce8\u91ca\u6216\u663e\u793a\uff0c\u5c06\u770b\u5230\u6253\u5370\u7684\u987a\u5e8f\u533a\u522b<\/span>\r\n\/\/        }\r\n\/\/        catch (InterruptedException x){}\r\n        System.out.println(\"\u5728main\u65b9\u6cd5\u4e2d-\u9000\u51fa\");\r\n\r\n\r\n    }\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\u7ed3\u679c\uff1a\r\n\u5728run\uff08\uff09\u65b9\u6cd5\u4e2d\uff0c-\u8fd9\u4e2a\u7ebf\u7a0b\u4f11\u772020\u79d2\r\n\u5728main\u65b9\u6cd5\u4e2d=\u4e2d\u65ad\u5176\u5b83\u7ebf\u7a0b\r\n\u5728main\u65b9\u6cd5\u4e2d-\u9000\u51fa\r\n\u5728run\u65b9\u6cd5\u4e2d-\u4e2d\u65ad\u7ebf\u7a0b\r\n\r\n\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/** * Created by xabcd on 2019\/2\/18. *\/ public class st [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,24],"tags":[],"class_list":["post-652","post","type-post","status-publish","format-standard","hentry","category-java","category-base_code"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=652"}],"version-history":[{"count":1,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/652\/revisions"}],"predecessor-version":[{"id":653,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/652\/revisions\/653"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}