class childthread implements Runnable
{
Thread t;
childthread()
{
t=new Thread(this,"odd");
System.out.println("child created "+t);
t.start();
}
public void run()
{
try
{
for(int i=1;i<10;i++)
{
System.out.println("child "+i);
i++;
Thread.sleep(500);
}
}
catch(InterruptedException e)
{}
}
}
class oddeventhread
{
public static void main(String[] s)
{
childthread c= new childthread();
try
{
for(int i=2;i<=10;i++)
{
System.out.println("even "+i);
i++;
Thread.sleep(1000);
}
}
catch(InterruptedException e)
{}
}
}
0 comments:
Post a Comment