2) Which method gets executed when the start() method of Thread class is called? [2] [6+4) 8 9 3) a. What will be the ou
Posted: Fri Apr 29, 2022 7:00 am
2) Which method gets executed when the start() method of Thread class is called? [2] [6+4) 8 9 3) a. What will be the output of the following program? b. Which functionality of Thread is violated in this code? How? 1 package ct5; 2 3 public class TestThread { 4 50 public static void main(String[] args) throws InterruptedException { 6 Thread t1 = new MyThread(); 7 Thread t2 = new MyThread(); Thread t3 = new MyThread(); t1.start(); 10 t1.join(); 11 t2.start(); 12 t2.join(); 13 t3.start(); 14 t3.join(); 15 System.out.println("Done"); 16 } 17 } 18 19 class My Thread extends Thread{ 200 public void run() { 21 for(int i=1; i<=5; i++) 22 System.out.println(Thread.currentThread().getName()+":"+i); 23 } 24 )