{"id":2694,"date":"2017-11-27T07:15:30","date_gmt":"2017-11-27T07:15:30","guid":{"rendered":"http:\/\/webartdevelopers.com\/?p=2694"},"modified":"2017-11-27T07:15:30","modified_gmt":"2017-11-27T07:15:30","slug":"how-to-create-a-thread-using-thread-class-in-core-java","status":"publish","type":"post","link":"https:\/\/webartdevelopers.com\/blog\/how-to-create-a-thread-using-thread-class-in-core-java\/","title":{"rendered":"How to Create a Thread using Thread class in Core Java"},"content":{"rendered":"<p>In this tutorial how to create a Thread using Thread class in Core Java is shown.<\/p>\n<p>Code:<\/p>\n<p>Thread1.java<\/p>\n<p>class MyThread extends Thread<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 ThreadDemo<br \/>\n{<br \/>\npublic static void main(String args[])<br \/>\n{<br \/>\nMyThread t1=new MyThread();<br \/>\nt1.start();<br \/>\n}<br \/>\n}<\/p>\n<p><a href=\"https:\/\/youtu.be\/RvO7SVBTjHY\">https:\/\/youtu.be\/RvO7SVBTjHY<\/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 Thread class in Core Java is shown. Code: Thread1.java class MyThread extends Thread { 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 ThreadDemo { public static void main(String args) { MyThread t1=new MyThread(); 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,187,188],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2694"}],"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=2694"}],"version-history":[{"count":2,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2694\/revisions"}],"predecessor-version":[{"id":2697,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2694\/revisions\/2697"}],"wp:attachment":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/media?parent=2694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/categories?post=2694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/tags?post=2694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}