What will be the output of the following program?
class NThread implements Runnable {
String str;
Thread t;
NThread(String nameofthread) {
str = nameofthread;
t = new Thread(this, str);
t.run();
}
public void run() {
try {
for (int i = 5; i > 3; i--) {
System.out.print(str + " : " + i + ", ");
Thread.sleep(100);
}
} catch (InterruptedException e) { System.out.println(str + "Interrupted"); }
System.out.println(str + " exiting");
}
}
class MultiThreadDemo {
public static void main(String[] args) {
new NThread("FIRST");
new NThread("SECOND");
new NThread("THIRD");
try {
Thread.sleep(100);
} catch (InterruptedException e) { System.out.println("Main Thread Interrupted"); }
System.out.println("Main Thread Exiting");
}
}