package multithreading;
class Test1 extends Thread
{
static Thread ChildTh;
@Override
public void run()
{
/* try
{
ChildTh.join(); // waiting for the main thread to complete
}
catch (InterruptedException e)
{
e.printStackTrace();
} */
for(int i = 65;i<75;i++)
{
System.out.print((char)i+" ");
}
}
}
public class Join_Exp
{
public static void main(String[] args)
{
Test1.ChildTh= Thread.currentThread();
Test1 t = new Test1();
t.start();
try
{
t.join(); // waiting for child thread to complete
}
catch (InterruptedException e)
{
e.printStackTrace();
}
for(int i = 65;i<75;i++)
{
System.out.print(i+" ");
}
}
}
class Test1 extends Thread
{
static Thread ChildTh;
@Override
public void run()
{
/* try
{
ChildTh.join(); // waiting for the main thread to complete
}
catch (InterruptedException e)
{
e.printStackTrace();
} */
for(int i = 65;i<75;i++)
{
System.out.print((char)i+" ");
}
}
}
public class Join_Exp
{
public static void main(String[] args)
{
Test1.ChildTh= Thread.currentThread();
Test1 t = new Test1();
t.start();
try
{
t.join(); // waiting for child thread to complete
}
catch (InterruptedException e)
{
e.printStackTrace();
}
for(int i = 65;i<75;i++)
{
System.out.print(i+" ");
}
}
}
No comments:
Post a Comment