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