Java Program on Main as a Thread
Get Job-ready: Java Course with 45+ 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);
}
}
}
You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

