PROGRAM TO MULTITHREADING in JAVA


class a extends Thread
{
public void run()
{
for(inti=0;i<=5;i++)
{
System.out.println(this.getName()+" :"+i);
}
System.out.println("The End of child Thread:"+this.getName());
}
}
class b extends Thread
{
public void run()
{
for(int i=0;i<=5;i++)
{
System.out.println(this.getName()+" :"+i);
}
System.out.println("The End of child Thread:"+this.getName());
}
}

class c extends Thread
{
public void run()
{
for(int i=0;i<=5;i++)
{
System.out.println(this.getName()+" :"+i);
}
System.out.println("The End of child Thread:"+this.getName());
}
}

class test
{
public static void main(String args[])

{
a thra=new a();
b thrb=new b();
c thrc=new c();

thra.setName("Thread_a");
thrb.setName("Thread_b");
thrc.setName("Thread_c");

thra.setPriority(Thread.MAX_PRIORITY);
thrb.setPriority(Thread.MIN_PRIORITY);
thrc.setPriority(Thread.NORM_PRIORITY);

System.out.println("start Thread b...");
thrb.start();

System.out.println("start Thread c...");
thrc.start();

System.out.println("start Thread a...");
thra.start();

try
{

thra.join();
thrb.join();
thrc.join();
}
catch(InterruptedException e)
{}

}
}

0 comments :