Question: I need help for the java homework, anyone help me? Note the following code. Assume that MyRunnable() is a class extending the Runnable interface. What's
I need help for the java homework, anyone help me?
Note the following code. Assume that MyRunnable() is a class extending the Runnable interface. What's the purpose of the highlighted code? public static void main(String[] args) {Thread t1 = new Thread(new MyRunnable(), "t1"); Thread t2 = new Thread(new MyRunnable(), "t2"); Thread t3 = new Thread(new MyRunnable(), "t3"); t1. start (); t2. start(); try {t1.join(); t2-join();} catch (InterruptedException e) {e.printStackTrace();} t3.start();} a. Forces program to wait until threads t1 & t2 are complete before starting t3. b. Forces program to wait until thread t1 is complete before starting t2. c. Threads t1 and t2 are potentially running concurrently d. Thread t2 isn't started until thread t1 is complete e. Answers A & C Thread.sleep (4000) will unscheduled the thread from execution for: a. 4000 seconds b. 4000 cycles c. 4 seconds d. 4 cycles Which method(s) have been deprecated in the Thread class? a. Start () b. Sleep () c. Stop () d. Interrupt ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
