MULTITHREADING
PROGRAM:
import [Link].*;
class evenThread extends Thread
{
evenThread()
{
super("demothread");
start();
}
public void run()
{
try
{
for(int i=1;i<=20;i=i+2)
{
[Link]("even no"+i);
[Link](200);
}
}
catch(InterruptedException ie)
{
[Link](ie);
}
[Link]("even thread terminates");
}
}
class oddThread extends Thread
{
oddThread()
{
super("demothread");
start();
}
public void run()
{
try
{
for(int i=1;i<=20;i=i+1)
{
[Link]("odd no"+i);
[Link](200);
}
}
catch(InterruptedException ie)
{
[Link]("even thread terminates");
}
}
}
class multiple5Thread extends Thread
{
multiple5Thread()
{
super("demothread");
start();
}
public void run()
{
try
{
for(int i=1;i<=50;i=i+5)
{
[Link]("even no"+i);
[Link](500);
}
}
catch(InterruptedException ie)
{
[Link]("multilpe5 thread terminates");
}
}
}
class sample
{
public static void main(Stirng str[])
{
evenThread t=new evenThread();
oddThread t1=new oddThread();
multiple5Thread t2=new multilpe5Thread();
try
{
[Link]();
[Link]();
[Link]();
}
catch(InterruptedException ie)
{
[Link](ie);
}
[Link]("Main thread terminates");
}
}