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");
}
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter