Given the following code,
_____________________________________________________
public class NiceThreads implements Runnable
{
public void run()
{
while(true)
{
}
}
public static void main(
String args[])
{
NiceThreads nt1 = new NiceThreads();
NiceThreads nt2 = new NiceThreads();
NiceThreads nt3 = new NiceThreads();
nt1.run();
nt2.run();
nt3.run();
}
}
_______________________________________________________________
1.The code does not compile - "nt2.run() is never reached"
2.The code compiles and runs 3 non ending non demon threads.
3.The code compiles but runs only 1 non ending, non demon
thread.
Correct Answer : 3.
The code compiles but runs only 1 non ending, non demon thread.
I expected the answer to 2.
Can anyone explain me the correct answer?
Thanks in advance,
rajani.