Java 31 - thread, contructor
Sun Nov 26 2023 17:15:33 GMT+0000 (Coordinated Universal Time)
Saved by
@Java
class Sample extends Thread
{
Sample()
{
super();
start();
}
public void run()
{
for(int i=0;i<3;i++)
{
try
{
System.out.println(Thread.currentThread().getName()+" - "+i);
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("hii");
}
}
}
}
class Main
{
public static void main(String[] args)
{
Sample t1=new Sample();
for(int i=0;i<3;i++)
{
try
{
System.out.println(Thread.currentThread().getName()+" - "+i);
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("hello");
}
}
}
}
content_copyCOPY
Comments