{"id":40347,"date":"2024-11-26T10:04:46","date_gmt":"2024-11-26T02:04:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/40347\/"},"modified":"2024-11-26T10:04:46","modified_gmt":"2024-11-26T02:04:46","slug":"tente-isto-%e4%bd%bf%e7%94%a8%e7%ba%bf%e7%a8%8b%e4%b8%bb%e4%bd%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/40347\/","title":{"rendered":"Tente Isto \u4f7f\u7528\u7ebf\u7a0b\u4e3b\u4f53"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173261378967132.jpg\" class=\"aligncenter\" title=\"Tente Isto \u4f7f\u7528\u7ebf\u7a0b\u4e3b\u4f53\u63d2\u56fe\" alt=\"Tente Isto \u4f7f\u7528\u7ebf\u7a0b\u4e3b\u4f53\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4e3b\u7ebf\u7a0b\uff1a<\/strong>\u6bcf\u4e2aJava\u7a0b\u5e8f\u90fd\u81f3\u5c11\u6709\u4e00\u4e2a\u6267\u884c\u7ebf\u7a0b\uff0c\u79f0\u4e3a\u4e3b\u7ebf\u7a0b\u3002\u4e3b\u7ebf\u7a0b\u5728\u6267\u884c\u65f6\u81ea\u52a8\u63d0\u4f9b\u7ed9\u7a0b\u5e8f\u3002<\/p>\n<p><strong>\u4e3b\u7ebf\u7a0b\u7684\u5904\u7406\uff1a<\/strong>\u867d\u7136\u5230\u73b0\u5728\u4e3a\u6b62\u5f88\u5c11\u4f7f\u7528\uff0c\u4f46\u4e3b\u7ebf\u7a0b\u53ef\u4ee5\u50cf\u7a0b\u5e8f\u4e2d\u7684\u5176\u4ed6\u7ebf\u7a0b\u4e00\u6837\u5bf9\u5f85\u3002<\/p>\n<p>1 \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a UseMn.java \u7684\u6587\u4ef6\u3002<\/p>\n<p>2 \u8981\u8bbf\u95ee\u4e3b\u7ebf\u7a0b\uff0c\u8bf7\u4f7f\u7528 Thread \u7c7b\u7684 currentThread() \u65b9\u6cd5\u3002 <br \/> \u6b64\u65b9\u6cd5\u8fd4\u56de\u5bf9\u5176\u8c03\u7528\u6240\u5728\u7ebf\u7a0b\u7684\u5f15\u7528\u3002<br \/> \u901a\u8fc7\u5728\u4e3b\u7ebf\u7a0b\u4e2d\u8c03\u7528 currentThread() \uff0c\u60a8\u5c06\u83b7\u5f97\u5bf9\u5176\u7684\u5f15\u7528\u3002<br \/> \u6709\u4e86\u8fd9\u4e2a\u53c2\u8003\uff0c\u5c31\u53ef\u4ee5\u50cf\u63a7\u5236\u4efb\u4f55\u5176\u4ed6\u7ebf\u7a0b\u4e00\u6837\u63a7\u5236\u4e3b\u7ebf\u7a0b\u3002<\/p>\n<p>3 \u5c06\u4ee5\u4e0b\u7a0b\u5e8f\u63d2\u5165\u6587\u4ef6\u4e2d\u3002\u5b83\u83b7\u53d6\u5bf9\u4e3b\u7ebf\u7a0b\u7684\u5f15\u7528\uff0c\u7136\u540e\u8bbf\u95ee\u5e76\u8bbe\u7f6e\u5176\u540d\u79f0\u548c\u4f18\u5148\u7ea7\u3002<\/p>\n<p>\u7c7b UseMain {<br \/> public static void main(String args[]) {<br \/> \u7ebf\u7a0b\u7b2c\u4e09\uff1b<br \/> \/\/ \u8bbf\u95ee\u4e3b\u7ebf\u7a0b\u3002<br \/> thrd = Thread.currentThread();<br \/> \/\/ \u663e\u793a\u4e3b\u7ebf\u7a0b\u7684\u540d\u79f0\u3002<br \/> System.out.println(&#8220;\u4e3b\u7ebf\u7a0b\u88ab\u8c03\u7528\uff1a&#8221; <br \/> thrd.getName());<br \/> \/\/ \u663e\u793a\u4e3b\u7ebf\u7a0b\u7684\u4f18\u5148\u7ea7\u3002<br \/> System.out.println(&#8220;\u4f18\u5148\u7ea7\uff1a&#8221; <br \/> thrd.getPriority());<br \/> System.out.println();<br \/> \/\/ \u5b9a\u4e49\u540d\u79f0\u548c\u4f18\u5148\u7ea7\u3002<br \/> System.out.println(&#8220;\u8bbe\u7f6e\u540d\u79f0\u548c\u4f18\u5148\u7ea7.n&#8221;);<br \/> thrd.setName(&#8220;\u7ebf\u7a0b #1&#8221;);<br \/> thrd.setPriority(Thread.NORM_PRIORITY 3);<br \/> System.out.println(&#8220;\u73b0\u5728\u8c03\u7528\u4e3b\u7ebf\u7a0b\uff1a&#8221; <br \/> thrd.getName());<br \/> System.out.println(&#8220;\u73b0\u5728\u4f18\u5148\u7ea7\u662f\uff1a&#8221; <br \/> thrd.getPriority());<br \/> }<br \/> }<\/p>\n<p>4 \u7a0b\u5e8f\u8f93\u51fa\u5982\u4e0b\u6240\u793a\uff1a<br \/> \u4e3b\u7ebf\u7a0b\u8c03\u7528\uff1amain<br \/> \u4f18\u5148\u7ea7\uff1a5<br \/> \u8bbe\u7f6e\u540d\u79f0\u548c\u4f18\u5148\u7ea7\u3002<br \/> \u4e3b\u7ebf\u7a0b\u73b0\u5728\u79f0\u4e3a\uff1a\u7ebf\u7a0b #1<br \/> \u73b0\u5728\u4f18\u5148\u7ea7\u662f\uff1a8<\/p>\n<p>5 \u5728\u4e3b\u7ebf\u7a0b\u4e0a\u6267\u884c\u7684\u64cd\u4f5c\u5fc5\u987b\u5c0f\u5fc3\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u6dfb\u52a0\u5230 main( ) \u7684\u672b\u5c3e\uff0c\u7a0b\u5e8f\u5c06\u6c38\u8fdc\u4e0d\u4f1a\u5b8c\u6210\uff0c\u56e0\u4e3a\u5b83\u5c06\u7b49\u5f85\u4e3b\u7ebf\u7a0b\u5b8c\u6210\uff01<br \/> \u5c1d\u8bd5{<br \/> thrd.join();<br \/> } catch(InterruptedException exc) {<br \/> System.out.println(&#8220;\u4e2d\u65ad&#8221;);<br \/> }<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fTente Isto \u4f7f\u7528\u7ebf\u7a0b\u4e3b\u4f53\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u7ebf\u7a0b\uff1a\u6bcf\u4e2aJava\u7a0b\u5e8f\u90fd\u81f3\u5c11\u6709\u4e00\u4e2a\u6267\u884c\u7ebf\u7a0b\uff0c\u79f0\u4e3a\u4e3b\u7ebf\u7a0b\u3002\u4e3b\u7ebf\u7a0b\u5728\u6267\u884c\u65f6\u81ea\u52a8\u63d0\u4f9b\u7ed9\u7a0b\u5e8f\u3002 \u4e3b\u7ebf\u7a0b\u7684\u5904\u7406\uff1a\u867d\u7136\u5230\u73b0\u5728\u4e3a\u6b62\u5f88\u5c11\u4f7f\u7528\uff0c\u4f46\u4e3b\u7ebf\u7a0b\u53ef\u4ee5\u50cf\u7a0b\u5e8f\u4e2d\u7684\u5176\u4ed6\u7ebf\u7a0b\u4e00\u6837\u5bf9\u5f85\u3002 1 \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a UseMn.java \u7684\u6587\u4ef6\u3002 2 \u8981\u8bbf\u95ee\u4e3b\u7ebf\u7a0b\uff0c\u8bf7\u4f7f\u7528 Thread \u7c7b\u7684 currentThread() \u65b9\u6cd5\u3002 \u6b64\u65b9\u6cd5\u8fd4\u56de\u5bf9\u5176\u8c03\u7528\u6240\u5728\u7ebf\u7a0b\u7684\u5f15\u7528\u3002 \u901a\u8fc7\u5728\u4e3b\u7ebf\u7a0b\u4e2d\u8c03\u7528 currentThread() \uff0c\u60a8\u5c06\u83b7\u5f97\u5bf9\u5176\u7684\u5f15\u7528\u3002 \u6709\u4e86\u8fd9\u4e2a\u53c2\u8003\uff0c\u5c31\u53ef\u4ee5\u50cf\u63a7\u5236\u4efb\u4f55\u5176\u4ed6\u7ebf\u7a0b\u4e00\u6837\u63a7\u5236\u4e3b\u7ebf\u7a0b\u3002 3 \u5c06\u4ee5\u4e0b\u7a0b\u5e8f\u63d2\u5165\u6587\u4ef6\u4e2d\u3002\u5b83\u83b7\u53d6\u5bf9\u4e3b\u7ebf\u7a0b\u7684\u5f15\u7528\uff0c\u7136\u540e\u8bbf\u95ee\u5e76\u8bbe\u7f6e\u5176\u540d\u79f0\u548c\u4f18\u5148\u7ea7\u3002 \u7c7b UseMain { public static void main(String args[]) { \u7ebf\u7a0b\u7b2c\u4e09\uff1b \/\/ \u8bbf\u95ee\u4e3b\u7ebf\u7a0b\u3002 thrd = Thread.currentThread(); \/\/ \u663e\u793a\u4e3b\u7ebf\u7a0b\u7684\u540d\u79f0\u3002 System.out.println(&#8220;\u4e3b\u7ebf\u7a0b\u88ab\u8c03\u7528\uff1a&#8221; thrd.getName()); \/\/ \u663e\u793a\u4e3b\u7ebf\u7a0b\u7684\u4f18\u5148\u7ea7\u3002 System.out.println(&#8220;\u4f18\u5148\u7ea7\uff1a&#8221; thrd.getPriority()); System.out.println(); \/\/ \u5b9a\u4e49\u540d\u79f0\u548c\u4f18\u5148\u7ea7\u3002 System.out.println(&#8220;\u8bbe\u7f6e\u540d\u79f0\u548c\u4f18\u5148\u7ea7.n&#8221;); thrd.setName(&#8220;\u7ebf\u7a0b #1&#8221;); thrd.setPriority(Thread.NORM_PRIORITY 3); System.out.println(&#8220;\u73b0\u5728\u8c03\u7528\u4e3b\u7ebf\u7a0b\uff1a&#8221; thrd.getName()); System.out.println(&#8220;\u73b0\u5728\u4f18\u5148\u7ea7\u662f\uff1a&#8221; thrd.getPriority()); } [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-40347","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/40347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=40347"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/40347\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=40347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=40347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=40347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}