Consider the following program and choose the best option:
class MyThread extends Thread { public void run() { System.out.print("Burp! "); }//from w ww . j a va2 s . c o m public static void main(String args[]) throws InterruptedException { Thread myThread = new MyThread(); myThread.start(); System.out.print ("Eat! "); myThread.join(); System.out.print ("Run! "); } }
b)
If the thread myThread is scheduled to run first immediately after start()
is called, it will print "Burp! Eat! Run!"; otherwise it will print "Eat! Burp! Run!" The output "Run!" will always be executed last because of the join()
method call in the main()
method.