class RunnableInterface implements Runnable
{
Thread t;
int i;
RunnableInterface()
{
t=new Thread(this,"Child Thread");
System.out.println("Child Thread is: "+t);
t.start();
}
public void run()
{
try
{
for(i=1;i<=5;i++)
{
System.out.println("Child Thread:"+i);
t.sleep(500);
}
}
catch(InterruptedException e)
{
System.out.println("Child Thread is Interrupted");
}
}
}
class MultipleThreadsRunnableInterface
{
public static void main(String args[])
{
new RunnableInterface();
try
{
for(int i=1;i<=5;i++)
{
System.out.println("Main Thread :"+i);
Thread.sleep(1000);
}
}
catch(InterruptedException e)
{
System.out.println("Main Thread Interrupted");
}
}
}