{"id":3975,"date":"2025-07-28T20:51:59","date_gmt":"2025-07-28T12:51:59","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=3975"},"modified":"2025-07-28T20:51:59","modified_gmt":"2025-07-28T12:51:59","slug":"%e5%a6%82%e6%9e%9c%e4%b8%80%e4%b8%aa%e7%ba%bf%e7%a8%8b%e4%b8%a4%e6%ac%a1%e8%b0%83%e7%94%a8start%ef%bc%8c%e4%bc%9a%e5%87%ba%e7%8e%b0%e4%bb%80%e4%b9%88%e9%97%ae%e9%a2%98%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/07\/28\/%e5%a6%82%e6%9e%9c%e4%b8%80%e4%b8%aa%e7%ba%bf%e7%a8%8b%e4%b8%a4%e6%ac%a1%e8%b0%83%e7%94%a8start%ef%bc%8c%e4%bc%9a%e5%87%ba%e7%8e%b0%e4%bb%80%e4%b9%88%e9%97%ae%e9%a2%98%ef%bc%9f\/","title":{"rendered":"\u5982\u679c\u4e00\u4e2a\u7ebf\u7a0b\u4e24\u6b21\u8c03\u7528start()\uff0c\u4f1a\u51fa\u73b0\u4ec0\u4e48\u95ee\u9898\uff1f"},"content":{"rendered":"\n<p>\u5982\u679c\u4e00\u4e2a\u7ebf\u7a0b\u5bf9\u8c61\uff08<code>Thread<\/code> \u5b9e\u4f8b\uff09<strong>\u8c03\u7528\u4e24\u6b21 <code>start()<\/code> \u65b9\u6cd5<\/strong>\uff0cJava \u865a\u62df\u673a\u4f1a\u629b\u51fa\u4e00\u4e2a <strong><code>IllegalThreadStateException<\/code> \u5f02\u5e38<\/strong>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u8be6\u7ec6\u89e3\u91ca\uff1a<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <code>start()<\/code> \u65b9\u6cd5\u7684\u4f5c\u7528<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>start()<\/code> \u4f1a\u542f\u52a8\u4e00\u4e2a\u65b0\u7ebf\u7a0b\uff0c\u5bfc\u81f4\u7ebf\u7a0b\u8fdb\u5165 <strong>\u53ef\u8fd0\u884c\uff08RUNNABLE\uff09\u72b6\u6001<\/strong>\uff0cJVM \u8c03\u5ea6\u6267\u884c <code>run()<\/code> \u65b9\u6cd5\u3002<\/li>\n\n\n\n<li>\u7ebf\u7a0b\u4e00\u65e6\u542f\u52a8\uff08\u8c03\u7528 <code>start()<\/code>\uff09\uff0c\u7ebf\u7a0b\u72b6\u6001\u4ece <code>NEW<\/code> \u53d8\u4e3a <code>RUNNABLE<\/code>\uff0c\u7ebf\u7a0b\u8fdb\u5165\u751f\u547d\u5468\u671f\u7684\u8fd0\u884c\u9636\u6bb5\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u4e3a\u4ec0\u4e48\u4e0d\u80fd\u8c03\u7528\u4e24\u6b21\uff1f<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Java \u7ebf\u7a0b\u5bf9\u8c61\u5bf9\u5e94\u4e00\u4e2a\u7ebf\u7a0b\u751f\u547d\u5468\u671f\uff0c<code>start()<\/code> \u53ea\u80fd\u8c03\u7528\u4e00\u6b21\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u7ebf\u7a0b\u5df2\u7ecf\u542f\u52a8\uff0c\u518d\u6b21\u8c03\u7528 <code>start()<\/code> \u662f\u975e\u6cd5\u64cd\u4f5c\u3002<\/li>\n\n\n\n<li>JVM \u4f1a\u68c0\u6d4b\u7ebf\u7a0b\u72b6\u6001\uff0c\u5982\u679c\u72b6\u6001\u4e0d\u662f <code>NEW<\/code>\uff0c\u8c03\u7528 <code>start()<\/code> \u5c31\u629b\u51fa\u5f02\u5e38\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u4ee3\u7801\u793a\u4f8b<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ThreadStartTwiceDemo {\n    public static void main(String&#91;] args) {\n        Thread t = new Thread(() -&gt; {\n            System.out.println(\"\u7ebf\u7a0b\u8fd0\u884c\u4e2d...\");\n        });\n\n        t.start();\n\n        try {\n            t.start();  \/\/ \u7b2c\u4e8c\u6b21\u8c03\u7528\uff0c\u629b\u51fa\u5f02\u5e38\n        } catch (IllegalThreadStateException e) {\n            System.out.println(\"\u5f02\u5e38\u6355\u83b7\uff1a\u7ebf\u7a0b\u5df2\u542f\u52a8\uff0c\u4e0d\u80fd\u518d\u6b21\u8c03\u7528start()\");\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u8f93\u51fa\u7ed3\u679c<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u7ebf\u7a0b\u8fd0\u884c\u4e2d...\n\u5f02\u5e38\u6355\u83b7\uff1a\u7ebf\u7a0b\u5df2\u542f\u52a8\uff0c\u4e0d\u80fd\u518d\u6b21\u8c03\u7528start()<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u7ebf\u7a0b\u72b6\u6001\u4e0e\u751f\u547d\u5468\u671f\u7b80\u8ff0<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7ebf\u7a0b\u72b6\u6001<\/th><th>\u662f\u5426\u5141\u8bb8\u8c03\u7528 <code>start()<\/code><\/th><\/tr><\/thead><tbody><tr><td>NEW<\/td><td>\u5141\u8bb8<\/td><\/tr><tr><td>RUNNABLE\u3001BLOCKED\u3001WAITING\u3001TIMED_WAITING<\/td><td>\u4e0d\u5141\u8bb8\uff0c\u8c03\u7528\u4f1a\u5f02\u5e38<\/td><\/tr><tr><td>TERMINATED<\/td><td>\u4e0d\u5141\u8bb8\uff0c\u8c03\u7528\u4f1a\u5f02\u5e38<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u8bbe\u8ba1\u539f\u56e0<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7ebf\u7a0b\u542f\u52a8\u540e\uff0c\u5176\u6267\u884c\u4ee3\u7801\u5728\u5e95\u5c42\u7ebf\u7a0b\u5df2\u7ecf\u5b58\u5728\uff0c\u5141\u8bb8\u91cd\u65b0\u8c03\u7528 <code>start()<\/code> \u4f1a\u5bfc\u81f4\u4e0d\u53ef\u9884\u6d4b\u884c\u4e3a\u3002<\/li>\n\n\n\n<li>JVM \u901a\u8fc7\u72b6\u6001\u673a\u9632\u6b62\u975e\u6cd5\u8c03\u7528\uff0c\u4fdd\u8bc1\u7ebf\u7a0b\u6a21\u578b\u4e00\u81f4\u6027\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u53c2\u8003\u8d44\u6599<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/lang\/Thread.html#start--\">Java\u5b98\u65b9\u6587\u6863 &#8211; Thread.start()<\/a><\/li>\n\n\n\n<li>\u300aJava\u5e76\u53d1\u7f16\u7a0b\u5b9e\u6218\u300b &#8211; \u7ebf\u7a0b\u751f\u547d\u5468\u671f\u7ae0\u8282<\/li>\n\n\n\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/2742454\/calling-thread-start-twice-throws-illegalthreadstateexception\">Stack Overflow &#8211; Calling start() twice throws IllegalThreadStateException<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u66f4\u591a\u8be6\u7ec6\u5185\u5bb9\u8bf7\u5173\u6ce8\u5176\u4ed6\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u4e00\u4e2a\u7ebf\u7a0b\u5bf9\u8c61\uff08Thread \u5b9e\u4f8b\uff09\u8c03\u7528\u4e24\u6b21 start() \u65b9\u6cd5\uff0cJava \u865a\u62df\u673a\u4f1a\u629b\u51fa\u4e00\u4e2a Illega [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3976,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68,86],"tags":[],"class_list":["post-3975","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-java-"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=3975"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3975\/revisions"}],"predecessor-version":[{"id":3977,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/3975\/revisions\/3977"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media\/3976"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=3975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=3975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=3975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}