{"id":2698,"date":"2017-11-27T07:22:12","date_gmt":"2017-11-27T07:22:12","guid":{"rendered":"http:\/\/webartdevelopers.com\/?p=2698"},"modified":"2017-11-27T07:22:12","modified_gmt":"2017-11-27T07:22:12","slug":"how-to-create-a-thread-using-runnable-interface-in-core-java","status":"publish","type":"post","link":"https:\/\/webartdevelopers.com\/blog\/how-to-create-a-thread-using-runnable-interface-in-core-java\/","title":{"rendered":"How to Create a Thread using Runnable Interface in Core Java"},"content":{"rendered":"<p>In this tutorial how to create a Thread using\u00a0Runnable Interface in Core Java is shown.<\/p>\n<p>Code:<\/p>\n<p>Thread2.java<\/p>\n<p>class MyThread implements Runnable<br \/>\n{<br \/>\npublic void run()<br \/>\n{<br \/>\ntry<br \/>\n{<br \/>\nfor(int i=0;i&lt;10;i++)<br \/>\n{<br \/>\nThread.sleep(2000);<br \/>\nSystem.out.print(&#8221; &#8220;+String.valueOf(i));<br \/>\n}<br \/>\n}<br \/>\ncatch(InterruptedException ie)<br \/>\n{<br \/>\nie.printStackTrace();<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>class RunnableDemo<br \/>\n{<br \/>\npublic static void main(String args[])<br \/>\n{<br \/>\nMyThread R1 = new MyThread();<br \/>\nThread t1 = new Thread(R1);<br \/>\nt1.start();<br \/>\n}<br \/>\n}<\/p>\n<p><a href=\"https:\/\/youtu.be\/8i-ubE9Pogw\">https:\/\/youtu.be\/8i-ubE9Pogw<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"In this tutorial how to create a Thread using\u00a0Runnable Interface in Core Java is shown. Code: Thread2.java class MyThread implements Runnable { public void run() { try { for(int i=0;i&lt;10;i++) { Thread.sleep(2000); System.out.print(&#8221; &#8220;+String.valueOf(i)); } } catch(InterruptedException ie) { ie.printStackTrace(); } } } class RunnableDemo { public static void main(String args) { MyThread R1 = new MyThread(); Thread t1 = new Thread(R1); t1.start(); } }<!-- AddThis Advanced Settings generic via filter on get_the_excerpt -->","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[156],"tags":[157,189,187],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2698"}],"collection":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/comments?post=2698"}],"version-history":[{"count":2,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2698\/revisions"}],"predecessor-version":[{"id":2700,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2698\/revisions\/2700"}],"wp:attachment":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/media?parent=2698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/categories?post=2698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/tags?post=2698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}