import java.lang.string;
class NewThread implements Runnable
{
void NewThread()
{
Thread t=new Thread(this,"demo");
System.out.println("child thread: " +t);
t.start();
}
void run()
{
try
{
for(int i=5;i>0;i--)
{
System.out.println("child thread: " +i");
Thread.sleep(500);
}
}
catch(InterruptedException e)
{
System.out.println("child interrupted ");
}
System.out.println("exiting child thread");
}
}
class lol
{
public static void main(String[] args)
{
new NewThread();
try
{
for(int i=5;i>0;i--)
{
System.out.println("main thread: " +i);
Thread.sleep(1000);
}
}
catch(InterruptedException e)
{
System.out.println("main thread interuupted");
}
System.out.println("main thread exiting");
}
}
class NewThread implements Runnable
{
void NewThread()
{
Thread t=new Thread(this,"demo");
System.out.println("child thread: " +t);
t.start();
}
void run()
{
try
{
for(int i=5;i>0;i--)
{
System.out.println("child thread: " +i");
Thread.sleep(500);
}
}
catch(InterruptedException e)
{
System.out.println("child interrupted ");
}
System.out.println("exiting child thread");
}
}
class lol
{
public static void main(String[] args)
{
new NewThread();
try
{
for(int i=5;i>0;i--)
{
System.out.println("main thread: " +i);
Thread.sleep(1000);
}
}
catch(InterruptedException e)
{
System.out.println("main thread interuupted");
}
System.out.println("main thread exiting");
}
}
No comments:
Post a Comment