Java Program on Main as a Thread
Free Java courses with 37 real-time projects - Learn Java
Program 1
package dataflair; public class TestMain { public static void main(String[] args) throws InterruptedException { System.out.println("Name of Main before change: "+ Thread.currentThread().getName()); Thread.currentThread().setName("My Main Thread"); System.out.println("Name of Main after change: "+ Thread.currentThread().getName()); Thread T=new Thread(); for(int i=1;i<=10;i++) { System.out.println(i); Thread.sleep(1000); } } }
Did you like this article? If Yes, please give DataFlair 5 Stars on Google