package multithreading;
//Main Thread Wait until Child Thread completes
public class MyThread5
{
public static void main(String[] args) throws InterruptedException
{
MyThreadJoin mj = new MyThreadJoin();
mj.start();
mj.join(); //-------------------Wait until Child Thread completes
char[] ch = {'e','t','y','r','w','d','g','h','t','s','e','b','n','l','k'};
for(char c : ch)
{
System.out.println(c);
try
{
Thread.sleep(200);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
}
class MyThreadJoin extends Thread
{
public void run()
{
int[] arr = {5,7,8,9,2,3,4,11,33,55,77,55,33,99,100};
for(int a : arr)
{
System.out.println(a);
try
{
Thread.sleep(200);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
}
//Main Thread Wait until Child Thread completes
public class MyThread5
{
public static void main(String[] args) throws InterruptedException
{
MyThreadJoin mj = new MyThreadJoin();
mj.start();
mj.join(); //-------------------Wait until Child Thread completes
char[] ch = {'e','t','y','r','w','d','g','h','t','s','e','b','n','l','k'};
for(char c : ch)
{
System.out.println(c);
try
{
Thread.sleep(200);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
}
class MyThreadJoin extends Thread
{
public void run()
{
int[] arr = {5,7,8,9,2,3,4,11,33,55,77,55,33,99,100};
for(int a : arr)
{
System.out.println(a);
try
{
Thread.sleep(200);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
}
No comments:
Post a Comment