class ImplementingRunnableInterface implements Runnable
{
Thread t;
ImplementingRunnableInterface(String n)
{
t=new Thread(this,n);
System.out.println("Thread is :"+t);
t.start();
}
public void run()
{
try
{
for(int i=1;i<=5;i++)
{
System.out.println(t.getName()+":"+i);
t.sleep(500);
}
}
catch(InterruptedException e)
{
System.out.println(t.getName()+" is Interrupted");
}
}
}
class TwoThreads
{
public static void main(String args[])
{
ImplementingRunnableInterface k1=new ImplementingRunnableInterface("Java Thread");
ImplementingRunnableInterface k2=new ImplementingRunnableInterface("Advanced Java Thread");
}
}