Java pleaseQuestion 3: Complete the Java code below, using wait() / notify appropriately, so that the correct total is printed i.e., after the count is done. (6 marks) public class Test public static void main(String[] args) { TotalRunr = new TotalRun(); Thread t = new Thread(); t.start(): while c em gereretanaRIN -N cat.tom/)&t.ntt; Animaler Badesky Puts Deursen t-get instawe notify(); 3 . Synchronized Call I. B e) / System.out.println(“Total is: ” +t total): -+-, synimniceal Lithis) & -class TotalRun implements Runnable int n = 0, total = 0; @Override public void run() { try & while Coc total) & wait (), Thread.sleep (200); } while (n<1000 ) {total += n++) These skeer wo: 3 innifalis catch (Intermobel Prepinize) ale patients Show transcribed image text Question 3: Complete the Java code below, using wait() / notify appropriately, so that the correct total is printed i.e., after the count is done. (6 marks) public class Test public static void main(String[] args) { TotalRunr = new TotalRun(); Thread t = new Thread(); t.start(): while c em gereretanaRIN -N cat.tom/)&t.ntt; Animaler Badesky Puts Deursen t-get instawe notify(); 3 . Synchronized Call I. B e) / System.out.println(“Total is: ” +t total): -+-, synimniceal Lithis) & -class TotalRun implements Runnable int n = 0, total = 0; @Override public void run() { try & while Coc total) & wait (), Thread.sleep (200); } while (n
Expert Answer
Answer to Question 3: Complete the Java code below, using wait() / notify appropriately, so that the correct total is printed i.e….