00:00
N49.png
/* N19 - code for driving licence making with join */ public class N49 extends Thread { public static void main(String[] args) throws InterruptedException { Medical m1 = new Medical(); m1.start(); m1.join(); // current thD WAIT TO JOIN AFTER m1 thread System.out.println(""); TestDrive t1 = new TestDrive(); t1.start(); t1.join(); // current thD WAIT TO JOIN AFTER t1 thread System.out.println(""); Signature s1 = new Signature(); s1.start(); } } class Medical extends Thread{ public void run(){ System.err.print("Medical Starts : "); try{ for(int i=1;i<=5;i++){ System.out.print(i+" " ); sleep(500); } } catch(Exception e1){ e1.getMessage(); } } } class TestDrive extends Thread{ public void run(){ System.err.print("TestDrive Starts : "); try{ for(int i=1;i<=5;i++){ System.out.print(i+" " ); sleep(500); } } catch(Exception e1){ e1.getMessage(); } } } class Signature extends Thread{ public void run(){ System.err.print("Signature Process Starts : "); try{ for(int i=1;i<=5;i++){ System.out.print(i+" " ); sleep(500); } } catch(Exception e1){ e1.getMessage(); } } } /* ramannegi@Ramans-MacBook-Pro x % javac N49.java ramannegi@Ramans-MacBook-Pro x % java N49 Medical Starts : 1 2 3 4 5 TestDrive Starts : 1 2 3 4 5 Signature Process Starts : 1 2 3 4 5 % */
Home PREVIOUS NEXT