{"id":147,"date":"2026-03-21T07:19:48","date_gmt":"2026-03-21T07:19:48","guid":{"rendered":"https:\/\/alpeshconnect.in\/blog\/?p=147"},"modified":"2026-03-21T07:19:48","modified_gmt":"2026-03-21T07:19:48","slug":"create-a-thread-that-prints-hello-from-thread-five-times-using-the-thread-class","status":"publish","type":"post","link":"https:\/\/alpeshconnect.in\/blog\/2026\/03\/21\/create-a-thread-that-prints-hello-from-thread-five-times-using-the-thread-class\/","title":{"rendered":"Create a thread that prints &#8221; Hello from Thread&#8221; five times using the Thread class"},"content":{"rendered":"\n<p>\/\/ Create a class that extends Thread<br>class MyThread extends Thread {<br>public void run() {<br>for (int i = 1; i &lt;= 5; i++) {<br>System.out.println(&#8220;Hello from Thread&#8221;);<br>}<br>}<br>}<\/p>\n\n\n\n<p>\/\/ Main class<br>public class ThreadExample {<br>public static void main(String[] args) {<br>\/\/ Create thread object<br>MyThread t = new MyThread();<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    \/\/ Start the thread\n    t.start();\n}<\/code><\/pre>\n\n\n\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ Create a class that extends Threadclass MyThread extends Thread {public void run() {for (int i = 1; i &lt;= 5; i++) {System.out.println(&#8220;Hello from Thread&#8221;);}}} \/\/ Main classpublic class ThreadExample {public static void main(String[] args) {\/\/ Create thread objectMyThread t = new MyThread(); }<\/p>\n","protected":false},"author":1,"featured_media":97,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,48],"tags":[25,26,49],"class_list":["post-147","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bca","category-java-programming-language","tag-bca","tag-bca-paper-solution","tag-java-programming-language"],"_links":{"self":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/comments?post=147"}],"version-history":[{"count":2,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":149,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/147\/revisions\/149"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/media\/97"}],"wp:attachment":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/media?parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/categories?post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/tags?post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}