/* Multiple Multithreading */
class Thread_1 extends Thread
{
public void run()
{
for(int i=1;i<=5;i++)
System.out.println("\tFrom Thread_1: i=" +i);
System.out.println("Exiting Thread_1");
}
}
class Thread_2 extends Thread
{
public void run()
{
for(int j=1;j<=5;j++)
System.out.println("\tFrom Thread_2: j=" +j);
System.out.println("Exiting Thread_2");
}
}
class Thread_3 extends Thread
{
public void run()
{
for(int k=1;k<=5;k++)
System.out.println("\tFrom Thread_3: k=" +k);
System.out.println("Exiting Thread_3");
}
}
class Main
{
public static void main(String args[])
{
Thread_1 t1=new Thread_1();
Thread_2 t2=new Thread_2();
Thread_3 t3=new Thread_3();
System.out.println("Starting Thread_1");
t1.start();
System.out.println("Starting Thread_2");
t2.start();
System.out.println("Starting Thread_3");
t3.start();
System.out.println("Exiting main thread");
}
}
No comments:
Post a Comment