{
Thread t;
mt()
{
t = new Thread(this, "Demo thread");
t.start();
}
public void run()
{
try
{
for(int i=1;i<=10;i++)
{
System.out.println(i);
t.sleep(1000);
}
}
catch(InterruptedException e)
{
System.out.println("Thread is interrupted");
}
}
};
class th
{
public static void main(String[] args)
{
mt t = new mt();
try
{
for (int i=2;i<=20;i=i+2)
{
System.out.println(i);
Thread.sleep(500);
}
}
catch(InterruptedException e)
{
}
}
}
No comments:
Post a Comment