Consider the following program and choose the correct answer:
class MyThread extends Thread { public MyThread(String name) { this.setName(name); }/*from w ww. j a va 2 s .com*/ public void run(){ try { sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } play(); } private void play() { System.out.print(getName()); System.out.print(getName()); } public static void main(String args[]) throws InterruptedException { Thread tableThread = new MyThread("Table"); Thread tennisThread = new MyThread("Tennis"); tableThread.start(); tennisThread.start(); } }
d)
Since the threads are not synchronized in this program, the output of this program cannot be determined.
Depending on how the threads are scheduled, it may even generate output such as Table Tennis Tennis Table.