{"id":953,"date":"2017-03-17T14:00:12","date_gmt":"2017-03-17T06:00:12","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=953"},"modified":"2017-03-17T14:00:12","modified_gmt":"2017-03-17T06:00:12","slug":"java%e5%9f%ba%e7%a1%80%e4%b9%8b%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%9a%84%e5%9f%ba%e6%9c%ac%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/java\/2017\/03\/17\/140012953.html","title":{"rendered":"Java\u57fa\u7840\u4e4b\u591a\u7ebf\u7a0b\u7684\u57fa\u672c\u5b9e\u73b0"},"content":{"rendered":"<p>1\u3001\u5b9e\u73b0\u65b9\u5f0f\u4e00\uff1a\u7ee7\u627fThread\u7c7b\uff0c\u91cd\u5199run\u65b9\u6cd5<\/p>\n<pre line=\"1\" lang=\"java\">\nclass Demo{\n\tpublic static void main(String [] args){\n\t\tSAThread thread1 = new SAThread();\n\t\tSAThread thread2 = new SAThread();\n\t\tthread1.start();\n\t\tthread2.start();\n\t}\n\t\n}\nclass SAThread extends Thread{\n\tpublic void run(){\n\t\tSystem.out.println(\"SAThread-->\"+Thread.currentThread());\n\t}\n}<\/pre>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<br \/>\nSAThread&#8211;>Thread[Thread-1,5,main]<br \/>\nSAThread&#8211;>Thread[Thread-0,5,main]<\/p>\n<p>2\u3001\u5b9e\u73b0Runnable\u63a5\u53e3\uff0c\u521b\u5efaThread\u5bf9\u8c61\u65f6\u5c06\u8be5\u63a5\u53e3\u5b9e\u4f8b\u4f20\u8fdb\u53bb\u5373\u53ef<\/p>\n<pre line=\"1\" lang=\"java\">\nclass Demo{\n\tpublic static void main(String [] args){\n\t\tSARunnable runnable = new SARunnable();\n\t\tThread thread1 = new Thread(runnable);\n\t\tThread thread2 = new Thread(runnable);\n\t\tthread1.start();\n\t\tthread2.start();\n\t}\n\t\n}\nclass SARunnable implements Runnable{\n\tpublic void run(){\n\t\tSystem.out.println(\"SAThread-->\"+Thread.currentThread());\n\t}\n}<\/pre>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<br \/>\nSAThread&#8211;>Thread[Thread-1,5,main]<br \/>\nSAThread&#8211;>Thread[Thread-0,5,main]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5b9e\u73b0\u65b9\u5f0f\u4e00\uff1a\u7ee7\u627fThread\u7c7b\uff0c\u91cd\u5199run\u65b9\u6cd5 class Demo{ public static void main(String [] args){ SAThread thread1 = new SAThread(); SAThread thread2 = new SAThread(); thread1.start(); thread2.start(); } } class SAThread extends Thread{ public void run(){ System.out.println(&#8220;SAThread&#8211;>&#8221;+Thread.currentThread()); } } \u8fd0\u884c\u7ed3\u679c\uff1a SAThread&#8211;>Thread[Thread-1,5,main] SAThread&#8211;>Thread[Thread-0,5,main] 2\u3001\u5b9e\u73b0Runnable\u63a5\u53e3\uff0c\u521b\u5efaThread\u5bf9\u8c61\u65f6\u5c06\u8be5\u63a5\u53e3\u5b9e\u4f8b\u4f20\u8fdb\u53bb\u5373\u53ef class Demo{ public static void main(String [] args){ SARunnable runnable = new SARunnable(); Thread thread1 = new Thread(runnable); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[34,20],"class_list":["post-953","post","type-post","status-publish","format-standard","hentry","category-java","tag-java","tag-basics"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=953"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/953\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}